Cordovalå¨iOSä¸çè¿ç¨æ´ç
ä¸ï¼å ³äºCordovalç论ç¥è¯
1:PhoneGapæ¯ææºå¹³å°ä¸æµè¡çä¸æ¬¾ä¸é´ä»¶ãå®æ建å¨åç§ææºå¹³å°ææä¾çWebViewï¼æµè§å¨å æ ¸ï¼ç»ä»¶çåºç¡ä¹ä¸ï¼ä½¿ç¨javascriptè¯è¨å¯¹åºç¨å¼åè æä¾ç»ä¸çæ¥å£ï¼å¦è°ç¨ç¸æºãè°ç¨å ¶ä»æ¬å°ç»ä»¶ï¼ï¼ä»èå±è½äºåææºå¹³å°ä¸OSçå¼æãå¨æ 线å°ç»çè°ç ä»»å¡ä¸ï¼æçä»»å¡ä¸»è¦æ¯è´è´£iOSå¹³å°ä¸çè°ç ï¼æ¬æç®åæè¿°äºiOSå¹³å°ä¸PhoneGapä¸å¹³å°æ¬å°çäºæä½æ§çå®ç°ã
2:PhoneGapå 为被æèµ ç»äºApacheèæ¹å为Cordovaï¼æ以PhoneGapéçç±»åé½ä»¥CDVä½ä¸ºåç¼ãå¨iOSå¹³å°ä¸ï¼æéè¦çä¸ä¸ªæ ¸å¿ç±»æ¯CDVViewControllerã该类ç´æ¥ç»§æ¿èªUIViewControllerï¼å èå ·å¤äºææUIViewControlleræå ·å¤çç¹æ§ãåæ¶ï¼è¯¥ç±»è¿å®ç°äºä¸¤ä¸ªProtocolï¼å³æ¥å£ï¼ï¼UIWebViewDelegateåCDVCommandDelegateãå æ¤å®ä¹è´è´£UIWebViewçä¸äºcallbackï¼ä»¥åCDVInvokedUrlCommandçæ§è¡ã
3:CDVViewControllerç±»ç主è¦å¯¹è±¡æåæ¯CDVCordovaView *webViewï¼å¨æºä»£ç ä¸å¯ä»¥çåºï¼è¿ä¸ªwebView对象æ¯CDVViewControllerçself.viewä¸çå¯ä¸è¢«addè¿æ¥çå对象ï¼å³è´è´£äºæ´ä¸ªCDVViewControllerç±»çæ¾ç¤ºãèCDVCordovaViewç±»å没ä»ä¹ç¹å«çï¼å®ç´æ¥ç»§æ¿èªUIWebViewã
4:å½CDVViewControllerå¨æ建æ¶ï¼å®æ两个å¾éè¦çå±æ§ï¼NSString*wwwFolderNameåNSString *startPageãè¿ä¸¤ä¸ªå±æ§å¼ä½¿å¾CDVViewControllerå¨loadä¹åç´æ¥å è½½wwwFolderNameä¸çstartPageä½ä¸ºåå§æ¾ç¤ºç页é¢ã
以ä¸æ¯å¯¹CDVViewControllerçä¸ä¸ªç®åä»ç»ã容ææç½çæ¯ï¼å¨iOSåºç¨ä¸ä½¿ç¨äºCDVViewControllerä¹åï¼çé¢å®é ä¸å°±å®å ¨äº¤ç»äºCDVCordovaView*webViewï¼å³ä¸ä¸ªUIWebViewã
äºï¼ä½¿ç¨Cordoval常碰å°çé®é¢
config.xml æ¯ä¸ä¸ªç¨æ¥é ç½®åºç¨çå ¨å±å±æ§çæ件, å¨æ¤æ件ä¸é ç½®çå±æ§åºè¯¥æ¯è½éåºææå¹³å°ç. å¨ç¼è¯çæ¶åé ç½®æ件å°ä¼è¢«ç¼è¯å°å¯¹åºçå¹³å°ä¸.
1ï¼å¦ä½å¨Cordovalå è½½è¿ç¨çURLç½å
å¨Config.xmlé ç½®æ件æ¶å¢å ä¸é¢ä¸¤ä¸ªï¼ä¾¿å¯ä»¥æå¼URLçHTML页é¢
<allow-navigation href="http://*/*" /> <allow-navigation href="https://*/*" />
2ï¼å¨Cordovalä¸å è½½åä¸ä¸ªåçURLæ¯å¨APPæå¼ï¼è·³è½¬å°å ¶å®å´æ¯ç¨safariæµè§å¨æå¼
åæ ·æ¯å¨Config.xmlé ç½®ä¸æä¸é¢ä¸¤ä¸ªå é¤ï¼è¿æ ·å®ä¾¿ä¼ä¸ç´å¨APPéé¢è¿è¡è·³è½¬
<!-- <allow-intent href="http://*/*" />--> <!-- <allow-intent href="https://*/*" />-->
2.1ï¼ç¦ç¨ WebViewBounce
UIWebViewæ¯iOS SDKä¸ä¸ä¸ªæ常ç¨çæ§ä»¶, å¨Cordovaä¸, é»è®¤ä¹æ¯ä½¿ç¨UIWebViewä½ä¸ºé»è®¤è§å¾æ¾ç¤ºæ们çHTMLåºç¨ç.
å¨ä½¿ç¨Cordovaç项ç®ä¸, é»è®¤WebViewBounceè¿ä¸ªé项æ¯æå¼ç, æ以使ç¨ææåä¸æè
åä¸æ»å¨å±å¹æ¶, ç»å¸¸ä¼çå°é¡µé¢åºé¨åå±å¹åºé¨ä¼åºç°ä¸å¤§ç空ç½, ç¶åæ¾å¼ææå, åå¼¹åå»çç¹æ.
<preference name="WebViewBounce" value="false" /> <preference name="DisallowOverscroll" value="true" />
2.2ï¼config.xml accessé ç½®
åªå 许google.com Access to google.com:
<access origin="http://google.com" />
åªå 许google.comçhttpsåè®® Access to the secure google.com (https://):
<access origin="https://google.com" />
äºçº§åå(maps) Access to the subdomain maps.google.com:
<access origin="http://maps.google.com" />
ææäºçº§åå Access to all the subdomains on google.com, for example mail.google.com and docs.google.com:
<access origin="http://*.google.com" />
ææåå Access to all domains, for example, google.com and developer.mozilla.org:
<access origin="*" />
2.3ï¼config.xml Navigation Whitelist
说æ:webviewå¯ä»¥è·³è½¬è³çURL
<!-- å 许ææå°example.comçé¾æ¥ --> <!-- Allow links to example.com --> <allow-navigation href="http://example.com/*" /> <!-- éé 符 --> <!-- Wildcards are allowed for the protocol, as a prefix to the host, or as a suffix to the path --> <allow-navigation href="*://*.example.com/*" /> <!-- éé 符(å ¨) *ä¸æ¨è* --> <!-- A wildcard can be used to whitelist the entire network, over HTTP and HTTPS. *NOT RECOMMENDED* --> <allow-navigation href="*" /> <!-- ä¸é¢çåæ³ä¸ä¸é¢3å¥çä»· --> <!-- The above is equivalent to these three declarations --> <allow-navigation href="http://*/*" /> <allow-navigation href="https://*/*" /> <allow-navigation href="data:*" />
2.4ï¼config.xml Intent Whitelist
说æ:ç³»ç»å¯ä»¥æå¼çé¾æ¥
<!-- Allow links to web pages to open in a browser --> <allow-intent href="http://*/*" /> <allow-intent href="https://*/*" /> <!-- Allow links to example.com to open in a browser --> <allow-intent href="http://example.com/*" /> <!-- Wildcards are allowed for the protocol, as a prefix to the host, or as a suffix to the path --> <allow-intent href="*://*.example.com/*" /> <!-- Allow SMS links to open messaging app --> <allow-intent href="sms:*" /> <!-- Allow tel: links to open the dialer --> <allow-intent href="tel:*" /> <!-- Allow geo: links to open maps --> <allow-intent href="geo:*" /> <!-- Allow all unrecognized URLs to open installed apps *NOT RECOMMENDED* --> <allow-intent href="*" />
2.5ï¼config.xml Network Request Whitelist
说æ:ç½ç»è¯·æ±(å¦XHRç)ç½åå
<!-- Allow images, xhrs, etc. to google.com --> <access origin="http://google.com" /> <access origin="https://google.com" /> <!-- Access to the subdomain maps.google.com --> <access origin="http://maps.google.com" /> <!-- Access to all the subdomains on google.com --> <access origin="http://*.google.com" /> <!-- Enable requests to content: URLs --> <access origin="content:///*" /> <!-- Don't block any requests --> <access origin="*" />
2.6ï¼index.html Content Security Policy
说æ:页é¢ä¸çèµæºç½åå
主è¦åè¿å ç±»:default-src,style-src,script-src,img-src,font-src,media-src ç
åæ°å¼å¯ä»¥æ¯:*,'self','unsafe-inline',data: ç
æ使ç¨çæ¯é常宽æ¾ççç¥:
å 许ææååçæ°æ®,å 许ä¸å®å ¨çå è,å 许data:(主è¦ç¨äºBASE64å½¢å¼çå¾ç,åä½ç)
<meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline';img-src * 'self' data:;font-src 'self' data:">
3ï¼å¦ä½å è½½ä¸åçå¯å¨é¡µURLå°å
å¨é ç½®Config.xmlæ件ä¸æ个contentçèç¹ï¼éé¢é»è®¤æ¯æä¸ä¸ªæå¼æ¬å°çå°åindex.html(æ¯å¦ï¼<content src="index.html" />); è¿ä¸ªå°±æ¯è·³è½¬å°æ¬å°å éé¢çhtml页é¢ï¼ä¹å¯ä»¥ä¿®æ¹æ(æ¯å¦ï¼<content src="https://www.baidu.com/" />)ï¼
ä¸é¢è¿ç§åªæ¯ä¿®æ¹é»è®¤çå°åï¼å¯è½ä¸ç¬¦å对äºé¡¹ç®å®é ç¨æ³ï¼é¡¹ç®ä¸è¦å è½½Cordovaé½ä¼æä¸ä¸ªviewControllerçæ§å¶å¨ç»§æ¿äºCDVViewControllerï¼å®æ¶å°±æä¸ä¸ªå±æ§startPageç¨äºè®¾ç½®è·³å°webViewå è½½çhtml页é¢ï¼å ¶ä¸ä½¿ç¨CDVViewControlleré常éè¦è®¾ç½®wwwFolderNameçç®å½å称ï¼åstartPageé¦é¡µçå称å³å¯ãé»è®¤wwwFolderName为www,startPageé»è®¤ä¸ºindex.html;è¿ä¸ªä¹æ¯æ¨¡æ¿ç´æ¥çææ¶æ件çå称ï¼
[email protected]"http://www.cnblogs.com";
4ï¼å¦ä½å è½½HTML页é¢åæ¾å¨çæ²ä¸
self.viewController = [[MainViewController alloc] init]; NSString *curFilePath=[NSString stringWithFormat:@"file://%@/www",[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]]; NSLog(@"è·¯å¾ä¸º:%@",curFilePath); if ([[NSFileManager defaultManager] fileExistsAtPath:curFilePath]) { self.viewController.wwwFolderName = curFilePath; } self.viewController.startPage=@"index.html";
åæ ·æ¯å¨wwwFolderNameä¸åæç« ï¼å 为å®æ¯åç¼æ件夹çè·¯å¾ï¼è¿è¾¹è¦æ³¨ææ¯å ³äºè·¯å¾è¦è¿ç¨file://æ¹å¼è¿è¡è¯»åï¼
å 为å¯ä»¥è¯»åæ²çéé¢çHTML页é¢ï¼è¿æ ·æ们就å¯ä»¥æ´å çµæ´»è¿ç¨ï¼æ¯å¦HTMLéè¿æå¡ç«¯å»ä¸è½½å°æ²ç解åï¼è¿æ ·å°±å¯ä»¥åå°å¨æä¿®æ¹ï¼
5:å 载页é¢è·ç»æå 载页é¢ççå¬ï¼æ两个éç¥å¯ä»¥çå¬ï¼ç¨æ¥å¤ççå¾ ææå±ç°
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; [center addObserver:self selector:@selector(onNotification:) name:CDVPluginResetNotification // å¼å§å è½½ object:nil]; [center addObserver:self selector:@selector(onNotificationed:) name:CDVPageDidLoadNotification // å è½½å®æ object:nil]; } - (void)onNotification:(NSNotification *)text{ NSLog(@"ï¼ï¼ï¼ï¼ï¼å¼å§çå¾ ------"); } - (void)onNotificationed:(NSNotification *)text{ NSLog(@"ï¼ï¼ï¼ï¼ï¼ç»æçå¾ ------"); }
6:å·æ°UIWebView,UIWebViewç´æ¥æ´æ¹url并reloadæ¯æ²¡æç¨çãå¿ é¡»å£°æä¸ä¸ªNSURLRequestï¼å¹¶éæ°loadRequestãå·æ°æ¶çurlå¿ é¡»æ¯ç¬¦åCordovaè§åçurlãå¨Cordovaæºç ä¸æä¸ä¸ªappUrlçæ¹æ³ï¼éè¿è¿ä¸ªæ¹æ³è½¬åºçurlæè½è¢«CDVViewControlleræ£å¸¸å è½½;
localWebVC.wwwFolderName = @"www"; localWebVC.startPage = @"local.html"; NSURL *url = [self.localWebVC performSelector:@selector(appUrl)]; if (url) { NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url]; [self.localWebVC.webView loadRequest:request]; }
7:使ç¨pod管çCordovalåå ¶æ件(IOS8以ä¸æå¯ä»¥ä½¿ç¨å°ææ°çæ¬)
pod 'Cordova'
å¦æéè¦å¼å ¥ä¸äºç¸å ³çæ件ï¼å¯ä»¥å å ¥å¦ä¸é ç½®ï¼ä¸é¢çè¿äºæ件å¯ä»¥éè¿podæç´¢å°ï¼
pod 'CordovaPlugin-console' pod 'cordova-plugin-camera' pod 'cordova-plugin-contacts' pod 'cordova-plugin-device' pod 'cordova-plugin-device-orientation' pod 'cordova-plugin-device-motion' pod 'cordova-plugin-globalization' pod 'cordova-plugin-geolocation' pod 'cordova-plugin-file' pod 'cordova-plugin-media-capture' pod 'cordova-plugin-network-information' pod 'cordova-plugin-splashscreen' pod 'cordova-plugin-inappbrowser' pod 'cordova-plugin-file-transfer' pod 'cordova-plugin-statusbar' pod 'cordova-plugin-vibration'
注æï¼å¦æ没æç¨podæ¥ç®¡çCordovaï¼é»è®¤å·¥ç¨é½ä¼æä¸ä¸ªCordovaLib.xcodeprojæ¥æCordovaçç±»å¼å ¥ï¼æ以建议Cordovaç¨podå¼å ¥ï¼å°±å¯ä»¥è°ç¨ï¼èå ³äºhtmlãJSçéæ模æ¿è¿æ¯å¨å·¥ç¨ä¸ï¼å¯ä»¥æ¥çä¸é¢ä¸¤ä¸ªç½å
iOSä¸Cordovaå¼ååæ¢ å°åï¼http://blog.devzeng.com/blog/hello-cordova-ios.html
Cordova使ç¨Podå®ä¾ å°åï¼https://github.com/phonegap/phonegap-webview-ios ãPODå¼å ¥ç模åé½åå¨ã
ä¸ï¼æ件å 容
对äºCordovaå¨æ件ä¸é¢è¿æ¯æ¯è¾å¤ï¼ä¹å¯ä»¥èªå®ä¹æ件çå¼åï¼å¯¹äºæ件ä¸é¢å·²ç»æååºä¸äºï¼å ¶å®æ件å¯ä»¥ä¸Cordovaæè gitHubè¿è¡æ¥æ¾ï¼
æ¯ä»å®æ¯ä»æä»¶ï¼ iOS/Android å°åï¼https://github.com/fami2u/cordova-plugin-alipay.git 微信æ¯ä»æä»¶ï¼ iOS/Android å°åï¼https://github.com/fami2u/cordova-plugin-weipay.git ping++æ¯ä»æä»¶ï¼ iOS å°åï¼https://github.com/fami2u/cordova-ping-fami.git æ«æäºç»´ç åæ¡å½¢ç æä»¶ï¼ iOS/Android å°åï¼https://github.com/fami2u/cordova-barcodescanner-fami.git æç §æä»¶ï¼ iOS/Android å°åï¼https://github.com/fami2u/cordova-plugin-camera.git æå æ¨éæä»¶ï¼ iOS/Android å°åï¼https://github.com/fami2u/jpush-phonegap-plugin.git iOS å°åï¼https://github.com/fami2u/cordova-Jpush-fami.git 第ä¸æ¹ç»å½æä»¶ï¼ iOS å°åï¼https://github.com/fami2u/cordova-UMLogin-fami.git JS å°åï¼https://github.com/fami2u/cordova-plugin-wechat.git 第ä¸æ¹å享æä»¶ï¼ iOS å°åï¼https://github.com/fami2u/cordova-UMShare-fami.git 跳转å°å¾æä»¶ï¼ iOS å°åï¼https://github.com/fami2u/cordova-plugin-map.git è§é¢ææ¾æä»¶ï¼ iOS å°åï¼https://github.com/fami2u/cordova-player-fami.git
åï¼æå¯è½åºç°çé®é¢
1ï¼å¨ä½¿ç¨cordova6.0çè¿ç¨ä¸ï¼ç¼è¯å¥½çAPPè¿è¡å¨IOS7+ç³»ç»ä¸é»è®¤æ¯ä¸ç¶ææ éå çï¼èè¿è¡å¨IOS6åèçæ¬ä¸æ¶æ¯äºç¶ææ å离çã
解å³åæ³ï¼ææ件MainViewController.mä¸çæ¹æ³viewWillAppearè¿è¡ç¸å ³ä¿®æ¹å¦ä¸ã ä½ç¨æ¯æ´æ¹viewçè¾¹çï¼ä½¿å ¶ä¸ç§»20pxï¼å好æ¯ç¶ææ çé«åº¦ã
- (void)viewWillAppear:(BOOL)animated { if([[[UIDevice currentDevice]systemVersion ] floatValue]>=7) { CGRect viewBounds=[self.webView bounds]; viewBounds.origin.y=20; viewBounds.size.height=viewBounds.size.height-20; self.webView.frame=viewBounds; } [super viewWillAppear:animated]; }
2ï¼å¨html页é¢å è°ç¨ç³»ç»ç¸æºä»¥ååè¿åï¼æ´ä¸ªé¡µé¢åºé¨ä¼æç½è²ç空ç½æ§ä»¶ï¼ç¨è°è¯å·¥å ·æ¥çå空ç½åºåçé«åº¦æ¯20px.该å¦ä½è§£å³ï¼
解å³åæ³ï¼ç±äºæ´ä¸ªcordova项ç®ç¸å½äºä¸ä¸ªé¡µé¢çåºç¨ï¼ä¸åç模åèéå¨ä¸èµ·ï¼æ以å½å½åå±å¹æ¶å¤±åï¼æ¯å¦è¿å ¥ç³»ç»ç¸æºæç §é¡µé¢ï¼ååºç°çæ¶åï¼è¿æ¯ä¼æ§è¡ä¸é¢ç代ç ï¼æ以çé¢é«åº¦å次åå°20px.
-(void)viewWillDisappear:(BOOL)animated { if([[[UIDevice currentDevice]systemVersion ] floatValue]>=7) { CGRect viewBounds=[self.webView bounds]; viewBounds.origin.y=20; viewBounds.size.height=viewBounds.size.height+20; self.webView.frame=viewBounds; } [super viewWillDisappear:animated]; }
äºï¼ä¸éç使ç¨æ»ç»ï¼
å ï¼JSè·OC交äºå®ä¾
1ï¼å 为Cordovalè¦è·JS交äºé½æ¯è¦å©ç¨CDVPluginè¿è¡
#import <Foundation/Foundation.h> #import <Cordova/CDVPlugin.h> @interface CDVHelloWorld : CDVPlugin -(void)sayHello:(CDVInvokedUrlCommand *)command; @end
æ以æ们å建ä¸ä¸ªæ件类ï¼ç»§æ¿äºCDVPluginç±»ï¼å ¶ä¸CDVInvokedUrlCommandå°±æ¯ç¨äºäº¤äºçç±»ï¼
#import "CDVHelloWorld.h" @implementation CDVHelloWorld -(void)sayHello:(CDVInvokedUrlCommand *)command { //æ¥æ¶JSä¼ è¿æ¥çå¼ NSDictionary *options=[command argumentAtIndex:0 withDefault:nil]; //对åºé®å NSString *curValue=options[@"quality"]; UIAlertView *myAlertView=[[UIAlertView alloc]initWithTitle:@"ææ¯å°å®ä¾" message:[NSString stringWithFormat:@"å½åçå 容ä»JSä¼ è¿æ¥çå¼ä¸ºï¼%@",curValue] delegate:self cancelButtonTitle:@"åæ¶" otherButtonTitles:@"ç¡®å®", nil]; [myAlertView show]; //æ°æ®åè° if ([curValue isEqualToString:@"200"]) { curValue=@"201"; } CDVPluginResult *pluginResult=[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"OCåè°è¿æ¥çå¼"]; [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; } @end
ä¸é¢çå®ä¾ææ¥æ¶JSä¼ è¿æ¥çå¼ï¼ä¹æååè°ç»JSçå¼ï¼åè°æ¶è¦å©ç¨self.commandDelegate;å ¶ä¸CDVPluginResultéé¢å æ¬å¾å¤ç¶æï¼ä¸é¢åªæ¯ææ£ç¡®çç¶æèµå¼ä¼ åå»ï¼èmessageAsStringåªæ¯ä¼å符串ï¼è¿æå ¶å®ç±»åçï¼æ¯è¾åå ¸ãæ°ç»çï¼
2ï¼config.xmlä¿®æ¹é ç½®ï¼æ³¨ååææ们注åçè¿ä¸ªæ件ï¼ç»å®å®ä¹ä¸ä¸ªHelloWorldçååï¼valueåæ¯æ们åæå建çç±»å
<feature name="HelloWorld"> <param name="ios-package" value="CDVHelloWorld" /> </feature>
3ï¼Htmlè·JSç代ç ï¼sayHelloåæ¯æ们类ä¸çä¸ä¸ªæ¹æ³åï¼HelloWorldåæ¯æ们å¨é ç½®ä¸çé£ä¸ªååï¼å¯ä»¥å¯¹å®è¿è¡ä¼ åï¼
<!DOCTYPE html> <html> <head> <title>Capture Photo</title> <script type="text/javascript" charset="utf-8" src="cordova.js"></script> <script type="text/javascript" charset="utf-8"> //ç®åè·OC交äºï¼æ²¡æåè° //function test() //{ // options={quality:"200"}; // cordova.exec(null,null,'HelloWorld','sayHello',[options]); //} function test() { options={quality:"200"}; cordova.exec( function(result){ var s=result; alert(s); }, function(error) { alert("error",error); } ,'HelloWorld','sayHello',[options]); } </script> </head> <body> <button onclick="test();">交äºOC</button> <br> </body> </html>
å¯ä»¥æ¥çæç« å¯¹äºæ件çç¼åæè¿ä¸æ¥ç说æï¼http://www.jianshu.com/p/e982b9a85ae8
ä¸ï¼å享Cordovaä¸éçæç« ï¼
使ç¨Cordovaè¿è¡iOSå¼å (ç¯å¢é ç½®ååºæ¬ç¨æ³) :http://www.jianshu.com/p/d24219c008b6
使ç¨Cordovaè¿è¡iOSå¼å (第ä¸æ¹æ件ç使ç¨ï¼Cameraæ件):http://www.jianshu.com/p/1e3d0c915dbc
使ç¨Cordovaè¿è¡iOSå¼å (å·²åç项ç®ä¸æ·»å Cordovaåèªå®ä¹æ件)ï¼http://www.jianshu.com/p/e982b9a85ae8
Cordovaæ件å¼åå ¥é¨ï¼IOSçOCè·JS交äºï¼:http://my.oschina.net/crazymus/blog/516388
æµ æ Cordova for iOS(OCè·JS交äºç说æ):http://www.cocoachina.com/industry/20130520/6238.html
cordova CDVViewController解æ :http://blog.****.net/u011417590/article/details/50895734
<preference>
å ³äºè¿ä¸ªæ ç¾çå¯ç¨è®¾ç½®æï¼
- DisallowOverscroll å¸å°å¼ï¼é»è®¤falseãå¦æä¸æ³è¦WebViewåºç°æ©¡ç®çæ»å¨æ¡ï¼å设置为true
- TopActivityIndicator å符串å¼ï¼é»è®¤grayã设置顶é¨ç¶ææ çé£æ ¼ï¼whiteLarge, white, gray
- EnableLocation å¸å°å¼ï¼ é»è®¤falseã 设置为trueï¼åå§ågpså®ä½æ件ã请设置Geolocationæ件çonloadå±æ§ä¸ºtrueã
- EnableViewportScale å¸å°å¼ï¼é»è®¤falseã设置为trueï¼ä»¥é²æ¢éè¿metaæ ç¾æ¥é¢è®¾viewport缩æ¾ã
- AutoHideSplashScreen å¸å°å¼ï¼é»è®¤trueã设置为falseï¼ä»¥æ§å¶å¯å¨ç»é¢ç±éè¿javascript APIæ¥éèã
- FadeSplashScreen å¸å°å¼ï¼é»è®¤ä¸ºtrueã设置为falseï¼ç¦æ¢å¯å¨ç»é¢æ·¡å ¥ææ·¡åºææã
- FadeSplashScreenDuration æµ®ç¹æ°ï¼é»è®¤ä¸º2ï¼ç§ï¼ãå¯å¨ç»é¢æ·¡å ¥æ·¡åºæ¶é´ã
- ShowSplashScreenSpinner å¸å°å¼ï¼é»è®¤ä¸ºtrueã设置为falseï¼åéèsplash-screen spinnerã
- MediaPlaybackRequiresUserAction å¸å°å¼ï¼é»è®¤ä¸ºfalseã设置为trueï¼åä¸å 许HTML5 videoèªå¨ææ¾ã
- AllowInlineMediaPlayback å¸å°å¼ï¼é»è®¤ä¸ºfalseã 设置为trueï¼åå 许å èHTML5 media playbackãå³ï¼å¨HTMLææ¡£çvideoå ç´ ä¹å¿ é¡»å«æwebkit-playsinlineå±æ§ã
- BackupWebStorage å符串å¼ï¼é»è®¤ä¸ºcloudãææç设置å¼æï¼noneãlocalåcloudã
- KeyboardDisplayRequiresUserAction å¸å°å¼ï¼é»è®¤ä¸ºtrueã 设置为false以æå¼é®çï¼å¨éè¿Javascript focus()èç¦è¡¨åå ç´ æ¶ã
- SuppressesIncrementalRendering å¸å°å¼ï¼ é»è®¤ä¸ºfalseã 设置为trueï¼å¨è¢«æ¸²æä¹åä¸ç´çå¾ ï¼ç´å°æææ°è§å¾å 容已ç»æ¥æ¶å°ã
- HideKeyboardFormAccessoryBar å¸å°å¼ï¼é»è®¤ä¸ºfalseã 设置为trueï¼éèé®ç顶é¨çå ¶ä»å·¥å ·æ æé®ï¼å¦Prev, Next, Doneã
- KeyboardShrinksView å¸å°å¼ï¼é»è®¤ä¸ºfalseã 设置为trueï¼åå½é®çåºç°å¨ä¸é¢æ¶ï¼æ¶ç¼©WebViewãThe WebView shrinks instead of the viewport shrinking and the page scrollable. This applies to apps that position their elements relative to the bottom of the WebView. This is the default behaviour on Android, and makes a lot of sense when building apps as opposed to webpages.