在iOS上使用Cordova 1.6设置外部启动页 [英] Setting an external startpage with Cordova 1.6 on iOS

查看:483
本文介绍了在iOS上使用Cordova 1.6设置外部启动页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以加载外部index.html(包括cordova.js)而不是本地代码?



我在appdelegate.m中找到此代码:

  self.viewController.wwwFolderName = @www; 
self.viewController.startPage = @index.html;

我试图引用外部URL但没有运气...任何人都知道这个解决方案? / p>

ps



与android相容很容易:

  super.loadUrl(http://192.168.1.135:3000/); 


解决方案

我已经为我的项目(AppDelegate.m ):

  self.viewController = [[[MainViewController alloc] init] autorelease]; 
self.viewController.useSplashScreen = YES; // YES;
self.viewController.wwwFolderName = @; // @www;
self.viewController.startPage = @; // @index.html;
self.viewController.invokeString = invokeString;
self.viewController.view.frame = viewBounds;

//使用新的根网址加载请求
NSURL * urlOverwrite = [NSURL URLWithString:@http://kyryll.com];
NSURLRequest * request = [NSURLRequest requestWithURL:urlOverwrite];

[self.viewController.webView loadRequest:request];

如其他地方所述,您尝试访问的网站必须列入白名单。



它工作得很好。我的外部网站是在本地IIS,并有cordova.js以及少数插件。现在只需要看看我是否得到苹果批准我的应用程序!


is it possible to load an external index.html (with included cordova.js) instead of the local one?

i found in the appdelegate.m this code:

self.viewController.wwwFolderName = @"www";
self.viewController.startPage = @"index.html";

i tried to reference an external url but without luck... anyone know a solution for this?

p.s.

with android it's easy:

super.loadUrl("http://192.168.1.135:3000/");

解决方案

I have done this for my project (AppDelegate.m):

self.viewController = [[[MainViewController alloc] init] autorelease];
self.viewController.useSplashScreen = YES; // YES;
self.viewController.wwwFolderName = @""; // @"www";
self.viewController.startPage = @""; // @"index.html";
self.viewController.invokeString = invokeString;
self.viewController.view.frame = viewBounds;

// Load request with new root URL
NSURL *urlOverwrite = [NSURL URLWithString:@"http://kyryll.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:urlOverwrite];

[self.viewController.webView loadRequest:request];

As mentioned elsewhere, the site you are trying access has to be whitelisted.

It's working nicely. My external site is on local IIS and has the cordova.js as well as few plugins. Now just have to see if I get Apple to approve my app!

这篇关于在iOS上使用Cordova 1.6设置外部启动页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆