近来有这样一个需求:其他的APP,想调用基于phonegap开发的iOS应用,并能跳转到指定界面,经过多次试验,终于成功。
在AppDelegate的openURL方法里,加入如下代码即可:
self.viewController.startPage=@"index.html"; //这里可设置跳转的界面
CDVCommandDelegateImpl *cmDelegate = [[CDVCommandDelegateImpl alloc] initWithViewController:self.viewController];
NSURL* startURL = [NSURL URLWithString:self.viewController.startPage];
NSString* startFilePath = [cmDelegate pathForResource:[startURL path]];
NSURL *appURL = [NSURL fileURLWithPath:startFilePath];
NSURLRequest* appReq = [NSURLRequest requestWithURL:appURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0];
[self.viewController.webView loadRequest:appReq];