phonegap如何解决ios7状态栏bar显示问题
来源:互联网 发布:青岛 阿里云 编辑:程序博客网 时间:2024/06/14 23:21
原文转自:http://www.it165.net/pro/html/201312/8574.html
在使用phonegap3.0的过程中,编译好的APP运行在IOS7系统上默认是与状态栏重叠的,而运行在IOS6及老版本中时是于状态栏分离的,如下图所示,是一个运行在IOS7下的默认状态下的APP
可以看出标题已经顶到状态栏了,如果再加上按钮,就不美观了。这时候我们可以用以下办法,使得状态栏和我们的应用分离:
Classes中找到MainViewController.m
在其中找到如下代码片段,并修改:
01.
- (
void
)viewWillAppear:(BOOL)animated
02.
{
03.
// View defaults to full size. If you want to customize the view's size, or its subviews (e.g. webView),
04.
// you can do so here.
05.
if
([[[UIDevice currentDevice] systemVersion] floatValue] >=
7
) {
06.
CGRect viewBounds = [self.webView bounds];
07.
viewBounds.origin.y =
20
;
08.
viewBounds.size.height = viewBounds.size.height -
20
;
09.
self.webView.frame = viewBounds;
10.
}
11.
[
super
viewWillAppear:animated];
12.
}
这样我们的应用运行起来是这样:
但是后来自己想了下,既然IOS7出来statubar和应用不再分离,也是有他的道理的,能否把APP做的既使用IOS7的特点又在IOS6上美观运行呢,我们可以这么改:
找到index.js
01.
var app = {
02.
// Application Constructor
03.
initialize: function() {
04.
this
.bindEvents();
05.
},
06.
// Bind Event Listeners
07.
//
08.
// Bind any events that are required on startup. Common events are:
09.
// 'load', 'deviceready', 'offline', and 'online'.
10.
bindEvents: function() {
11.
document.addEventListener(
'deviceready'
,
this
.onDeviceReady,
false
);
12.
},
13.
// deviceready Event Handler
14.
//
15.
// The scope of 'this' is the event. In order to call the 'receivedEvent'
16.
// function, we must explicity call 'app.receivedEvent(...);'
17.
onDeviceReady: function() {
18.
if
(window.device.version.substr(
0
,
1
) ===
'7'
) {
19.
$('
').addClass('ios7').prependTo($('body')); } app.receivedEvent('deviceready'); }, // Update DOM on a Received Event receivedEvent: function(id) { // var parentElement = document.getElementById(id); // var listeningElement = parentElement.querySelector('.listening'); // var receivedElement = parentElement.querySelector('.received'); // // listeningElement.setAttribute('style', 'display:none;'); // receivedElement.setAttribute('style', 'display:block;'); // // console.log('Received Event: ' + id); } };
主要是这一段
if (window.device.version.substr(0,1) === '7') {
$('
').addClass('ios7').prependTo($('body'));
}
运行后效果:
}
注意:device这个变量想要使用必须先安装phonegap的device插件
.ios7的CSS:
1.
.ios7{
2.
background-color: #761C10;
3.
height: 20px;
4.
}
运行后效果:
方法有很多种,大家自己想想哪个适合自己吧。
0 0
- phonegap如何解决ios7状态栏bar显示问题
- phonegap如何解决ios7状态栏bar显示问题
- [Phonegap+Sencha Touch] 移动开发20 IOS7状态栏问题
- [Phonegap+Sencha Touch] 移动开发20 IOS7状态栏问题
- iOS7隐藏状态栏 status Bar
- iOS7隐藏状态栏 status Bar
- IOS7隐藏状态栏 status Bar
- iOS7隐藏状态栏 status Bar
- iOS7隐藏状态栏 status Bar
- iOS7隐藏状态栏 status Bar
- iOS7隐藏状态栏 status Bar
- iOS7隐藏状态栏 status Bar
- iOS7隐藏状态栏 status Bar
- phonegap3+,ios7+ 状态栏问题的解决
- IOS7状态栏遮盖问题分析解决
- 解决在iphone(ios7)中状态栏(Status bar)会覆盖(overlap)在软件(view)上的问题
- phonegap解决iphone顶部状态栏位置的问题
- iOS7如何隐藏状态栏
- 日语学习之沪江N3基础 20150622 -3
- UITableView代理cellForRowAtIndexPath不执行的相关解决方案
- centos7服务安装_SAMBA服务
- STOMP协议详解
- Servlet中编码问题
- phonegap如何解决ios7状态栏bar显示问题
- java web中的request和respone
- 使用 RHEL 6.5 DVD 做本地 YUM 源
- LeetCode 题解(112): Substring with Concatenation of All Words
- Android学习笔记之—采用Pull解析XML文件
- 使用Xcode 7 beta免费真机调试iOS应用程序
- iOS开发之旅--深入讲解Singleton(单例设计模式)
- 关于递归删除链表节点为什么不会断链问题解释
- 第24题:原地逆置单链表