欢迎访问 夜阑小雨 我的学习碎片档案,这里记录了我的学习内容和工作中经验,希望给您带去帮助。

Phonegap的一些设置

phonegap开发 夜阑小雨 1015℃ 0评论

Phonegap相关
1. 隐藏顶部的状态栏
在xxx-Info.plist中新增一项属性:”Status bar is initially hidden” = YES;此外,还可以增加其他的属性,例如Launch image等。

2. 用户滑动Webview时,正常情况下会超出边界然后弹回来,也就是Bounce,可以通过Cordova.plist中的属性来实现了。
*对于老版本的,在AppDelegate.m中的webViewDidFinishLoad方法中添加:

  1. for(id subview in theWebView.subviews)
  2. if([[subview class] isSubclassOfClass:[UIScrollViewclass]])
  3. ((UIScrollView*)subview).bounces = NO;

 

3. Phonegap 内购 IAP插件
https://github.com/phonegap/phonegap-plugins/tree/master/iPhone/InAppPurchaseManager

4. 修改Bounce时的背景色

theWebView.backgroundColor =[UIColorgrayColor];

5. Phonegap的deviceready事件通常要比DOMContentLoaded后触发。

Webkit相关

1. 防止页面一定位数的数字自动变成链接
当页面上存在一定位数的数字(例如8位)时,会突然自己变成链接,实际上是被webkit自动解析成电话号码了,可以通过以下方式禁止:
在Classes中的AppDelegate.m中的webViewDidStartLoad中添加:

  1. theWebView.dataDetectorTypes =UIDataDetectorTypeNone;

如果是在Safari中则可以通过添加相关的meta标签来设置,而在phonegap中则只能修改OC代码。

2. 阻止a标签长按后打开提示框
长按A标签后,iOS会从底部弹出一个列表,允许你选择以何种方式打开,如果要禁止这种提示时,可以添加下列css属性:

  1. webkittouchcallout:none

3. 长按A标签会造成一定区域出现“蒙板式”的阴影,解决方案是添加以下的CSS代码(只在ipad和iphone中有效)

  1. *{
  2. webkittouchcallout: none;/* prevent callout to copy image, etc when tap to hold */
  3. webkittextsizeadjust: none;/* prevent webkit from resizing text to fit */
  4. webkittaphighlightcolor: rgba(0,0,0,0);/* make transparent link selection, adjust last value opacity 0 to 1.0 */
  5. webkituserselect: none;/* prevent copy paste, to allow, change ‘none’ to ‘text’ */
  6. }

4. 监听视频播放时的全屏事件

  1. // 进入全屏
  2. video.bind(webkitbeginfullscreen’,function(){
  3. alert(begin);
  4. });
  5. // 结束全屏
  6. video.bind(webkitendfullscreen’,function(){
  7. alert(end);
  8. });

转载请注明:夜阑小雨 » Phonegap的一些设置

喜欢 (0)or分享 (0)
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址