【问题标题】:How can i get the alert in click of submit?如何在点击提交时获得警报?
【发布时间】:2016-02-11 08:36:13
【问题描述】:

如何在点击提交时获得提醒?
我正在使用 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];

提前致谢..

【问题讨论】:

    标签: ios objective-c uiwebview


    【解决方案1】:

    检查一下:

    - (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。

    希望这会有所帮助。

    【讨论】:

    【解决方案2】:

    1 - 将 IBAction 添加到您的提交按钮。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-24
      • 2012-11-21
      • 1970-01-01
      • 1970-01-01
      • 2016-02-13
      • 1970-01-01
      • 1970-01-01
      • 2011-10-18
      相关资源
      最近更新 更多