Может быть, я опаздываю, но ответ на первые два вопроса ДА можно. Вы можете вызвать метод Objective C, который имеет средство выбора, отображающее коды, и навигацию/проталкивание других представлений из вашей сети с Javascript. Вам просто нужно отслеживать их в своем родном приложении с помощью UIWebViewDelegate. Вот пример, как я это сделал:
// В вашем файле Javascript, внутри метода, из которого вы хотите вызвать Pickerview или хотите отправить другое собственное представление
var iframe = document.createElement("IFRAME");
iframe.setAttribute("src", "js-frame:myObjectiveCFunction";
document.documentElement.appendChild(iframe);
iframe.parentNode.removeChild(iframe);
iframe = null;
В файле Native Objective-C: включите ‹‹UIWebViewDelegate>>
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType {
if ([[[request URL] absoluteString] hasPrefix:@"js-frame:"]) {
// Extract the selector name from the URL
NSArray *components = [requestString componentsSeparatedByString:@":"];
NSString *functionName = [components objectAtIndex:1];
// Call the given selector
[self performSelector:NSSelectorFromString(functionName)];
// Cancel the location change
return NO;
}
// Accept this location change
return YES;
}
- (void)myObjectiveCFunction {
// Do whatever you want!
// show Native picker view
// Push another native View
}
Точно так же вы даже можете отправить параметры с HTML-страницы в Objective c. // --------------------------------------------------
person
Samir Jwarchan
schedule
21.09.2012