如何通过点击提交获得提醒?

时间:2016-02-11 08:36:14

标签: ios objective-c uiwebview

enter image description here

如何通过点击提交获得提醒?
我正在使用WebView ..

这是代码

UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];

[webView setDelegate:self];

NSString *urlAddress = @“sssssss”;
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];

[self.view addSubview:webView];

先谢谢..

2 个答案:

答案 0 :(得分:3)

检查一下:

- (BOOL)webView: (UIWebView*)webView shouldStartLoadWithRequest: (NSURLRequest*)request navigationType: (UIWebViewNavigationType)navigationType {
      NSString *fragment, *scheme;
      if (navigationType == UIWebViewNavigationTypeLinkClicked) {
           //1
           [webView stopLoading];
           fragment = [[request URL] fragment];
           scheme = [[request URL] scheme];

           if ([scheme isEqualToString: @"file"] && [self respondsToSelector: NSSelectorFromString(fragment)]) {
               [self performSelector: NSSelectorFromString(fragment)];
               return NO;
           }

           [[UIApplication sharedApplication] openURL: [request URL]];
      }
      return YES;
}

您需要将委托设置为WebView。

希望这有帮助。

答案 1 :(得分:-3)

1 - 在提交按钮中添加IBAction。

2 - 在被调用的方法内部使用UIAlertController创建一个警告,该警告将在单击按钮时显示。