我想通過HTML表單和ios之間的信息我試過javascrip但它不工作?UIwebview中的HTML表單發送回ios?
// Init Web View
UIWebView *webView;
webView = [[UIWebView alloc] initWithFrame:boundsRect];
webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
webView.scalesPageToFit = YES;
webView.contentMode = UIViewContentModeCenter;
webView.multipleTouchEnabled = NO;
webView.userInteractionEnabled = YES;
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
[self addSubview:webView];
NSString *testArrayString = [webView stringByEvaluatingJavaScriptFromString:@"testString"];
NSArray *testArray = [testArrayString componentsSeparatedByString:@"#"];
NSLog(@"%@", testArray);
[webView release];
return self;
有什麼想法嗎?
---- ----編輯
玉傢伙,如果只想要使從表單數據傳遞給iOS應用程序,你只能這樣做,以你的WebView
[webView setDelegate:self];
然後你可以實現這個方法在你的程序,標誌着
,如:
-(void)webViewDidFinishLoad:(UIWebView *) webView {
//implement code to do here
}
,如果你想捕捉對於j烏斯季做的WebView shouldStartWithRequest這樣的:
-(BOOL)webView:(UIwebView *) webView shouStartWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigation{
//implement code to do afeter the user click the form don't forget to return YES or NO because it is a BOOL
}
是我如何解決它的任何問題,請不要告訴我,我盡我所能來幫助
'stringByEvaluatingJavaScriptFromString:'希望你傳遞一個JavaScript代碼段,它將在網絡視圖的上下文中進行評估。 'testString'沒有意義,它不是JavaScript,所以什麼也沒有發生。 – Jasarien