Использовали ли вы Плагин для дочернего браузера , этот плагин также содержит ChildBrowserViewController.xib. Таким образом, чтобы вызвать другой xib в вашем Phonegap, вам нужно изменить - (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
метод в файле appDelgate.m.
Как-то в вашем HTML и javascript-коде вам нужно предоставить специальную ссылку (используя метод href или window.location), которую вам нужно обработать в методе shouldStartLoadWithRequest
, импортируйте #import MyCustomViewController.h
в файл appDelegate.m.
Пожалуйста, посмотрите на следующий фрагмент-
- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
//return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
NSURL *url = [request URL];
if([request.URL.absoluteString isEqualToString:@"about:blank"])
return [ super webView:theWebView shouldStartLoadWithRequest:request
navigationType:navigationType ];
if ([[url scheme] isEqualToString:@"gap"]) {
return [ super webView:theWebView shouldStartLoadWithRequest:request
navigationType:navigationType ];
}
else {
NSString *urlFormat = [[[url path] componentsSeparatedByString:@"."] lastObject];
if ([urlFormat compare:@"xib"] == NSOrderedSame) {
[theWebView sizeToFit];
MyCustomViewController* customVC = [ [ MyCustomViewController alloc ] initWithScale:FALSE ];
customVC.modalPresentationStyle = UIModalPresentationFormSheet;
customVC.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[super.viewController presentModalViewController:customVC animated:YES ];
[customVC release];
//return YES;
return NO;
}
else
return [ super webView:theWebView shouldStartLoadWithRequest:request
navigationType:navigationType ];
}
}
спасибо,
Mayur