默認(rèn)情況下Cordova是不能調(diào)用外部網(wǎng)址的,需要做一些配置,也是非常簡單的。
1、打開圈圈的文件
Paste_Image.png
2、看看框中的的內(nèi)容在你的工程中有嗎?,沒有的話加上,一般都是自動生成的。
Paste_Image.png
3、在cordova框架中,有一個類是設(shè)置阻止加載外部網(wǎng)頁的。點擊xcode中的搜索
Paste_Image.png
- 點擊框中的<code>CDVIntentAndNavigationFilter
Paste_Image.png
這個方法就是cordova阻止加載外部網(wǎng)頁的代碼:
Paste_Image.png
只需要將上面方法中的內(nèi)容更換為:
- (void)parserDidStartDocument:(NSXMLParser*)parser { // file: url <allow-navigations> are added by default // self.allowNavigations = [[NSMutableArray alloc] initWithArray:@[ @"file://" ]]; self.allowNavigations = [[NSMutableArray alloc] initWithArray:@[ @"file://" , @"http://", @"https://", @"xxxxxschemes://"]]; // no intents are added by default self.allowIntents = [[NSMutableArray alloc] init]; }
完活!!!!
Paste_Image.png