+1
-3

Phongap开发问题汇总

admin 发表于 2012年03月15日 23:04 | Hits: 3869
Tag: 移动开发 | html5 | Phonegap

Phonegap相关

1. 隐藏顶部的状态栏

         在xxx-Info.plist中新增一项属性:"Status bar is initially hidden" = YES;此外,还可以增加其他的属性,例如Launch image等。

2. 用户滑动Webview时,正常情况下会超出边界然后弹回来,也就是Bounce,可以通过以下方式禁止这种行为:

在AppDelegate.m中的webViewDidFinishLoad方法中添加:

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

不过在Phonegap1.5版本中已经可以通过Phonegap.plist中的属性来实现了。

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中添加
theWebView.dataDetectorTypes = UIDataDetectorTypeNone;

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

2. 阻止a标签长按后打开提示框

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

3. 长按A标签会造成一定区域出现“蒙板式”的阴影,解决方案是添加以下的CSS代码(只在ipad和iphone中有效)
*{-webkit-tap-highlight-color:rgba(0,0,0,0);}

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

               // 进入全屏
               video.bind( ‘webkitbeginfullscreen’, function() {
                    alert( ‘begin’ );
               } );             

               // 结束全屏
               video.bind( ‘webkitendfullscreen’, function() {
                    alert( ‘end’ );
               } );

5. CPU被独占时,Timer会停止,因此需要考虑应对策略。

其他问题

1. IAP如果遇到问题可以检查以下选项

机器是否越狱,越狱无法测试,query时会返回invalidProductId

Have you enabled In-App Purchases for your App ID?

Have you checked Cleared for Sale for your product?

Does your project’s .plist Bundle ID match your App ID?

Have you configured your project to code sign using this new provisioning profile?Are you using the full product ID when when making an SKProductRequest?Are your bank details active on iTunes Connect?Contracts, Tax, and Banking全部显示Contacts In Effect

Have you tried deleting the app from your device and reinstalling?

2. APN服务器端 pem的生成
Installing the SSL Certificate and Key on the ServerYou should install the SSL distribution certificate and private cryptographic key you obtained earlier on the server computer on which the provider code runs and from which it connects with the sandbox or production versions of APNs. To do so, complete the following steps:

  1). Open Keychain Access utility and click the My Certificates category in the left pane.

  2). Find the certificate you want to install and disclose its contents.
You’ll see both a certificate and a private key.

  3). Select both the certificate and key, choose File > Export Items, and export them as a Personal Information Exchange (.p12) file.

  4). Servers implemented in languages such as Ruby and Perl often are better able to deal with certificates in the Personal Information Exchange format. To convert the certificate to this format, complete the following steps:

    (1). In KeyChain Access, select the certificate and choose File > Export Items. Select the Personal Information Exchange (.p12) option, select a save location, and click Save.

    (2). Launch the Terminal application and enter the following command after the prompt:
openssl pkcs12 -in CertificateName.p12 -out CertificateName.pem -nodes

  5). Copy the .pem certificate to the new computer and install it in the appropriate place.

注意:经测试,<iOS5的设备如果连了VPN会收不到PUSH(可以用电脑共享的网络),iOS5是可以的。

3. 手机中打开iTunes链接

itms-apps://+链接

原文链接: http://varnow.org/?p=355

-3     +1

我要给这篇文章打分:

可以不填写评论, 而只是打分. 如果发表评论, 你可以给的分值是-5到+5, 否则, 你只能评-1, +1两种分数. 你的评论可能需要审核.

评价列表(4)

  • +1 guest voted at 2012-03-28 09:48:32

  • -1 guest voted at 2012-08-23 16:18:13

  • -1 guest voted at 2012-08-23 16:31:05

  • -1 guest voted at 2012-08-23 16:57:58