我有一个付款html页面,我在iOS应用程序的web视图中加载了该页面。单击表单中的提交按钮时,我想在目标C中编写一些代码。我知道我们可以使用这种NavigationType来检测点击,但这不起作用:
-(BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
if (navigationType == UIWebViewNavigationTypeFormSubmitted) {
NSLog("inside submit");
}
return YES;
}
请让我知道我们是否可以通过其他方式进行。
首先,您需要设置UIWebViewDelegate方法,然后给我提供示例导航代码。您需要在此处进行自定义。
#pragma mark - UIWebView Delgate Method
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
switch (navigationType)
{
case UIWebViewNavigationTypeLinkClicked:
//When User tapped a link.
break;
case UIWebViewNavigationTypeOther:
//Some other action occurred.
break;
case UIWebViewNavigationTypeFormSubmitted:
//user submitted a form.
break;
case UIWebViewNavigationTypeBackForward:
//User tapped the back or forward button. .
break;
case UIWebViewNavigationTypeReload:
//User tapped the reload button.
break;
case UIWebViewNavigationTypeFormResubmitted
//User resubmitted a form. .
break;
}
return YES;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句