Ios 使用UIWebview进行呼叫时,如何知道单击了UIAlertView的哪个按钮索引

Ios 使用UIWebview进行呼叫时,如何知道单击了UIAlertView的哪个按钮索引,ios,uiwebview,phone-call,Ios,Uiwebview,Phone Call,我能够生成一个警报,允许用户使用UIWebView调用此代码: UIWebView *webV= [[UIWebView alloc] init]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"tel:1834563578"]]; [webV loadRequest:request]; 但是,当我使用UIWebView进行呼叫时,系统会发出警报。我想知道用户选择了哪个按钮索引。我不知道如

我能够生成一个警报,允许用户使用
UIWebView
调用此代码:

UIWebView *webV= [[UIWebView alloc] init];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"tel:1834563578"]];
[webV loadRequest:request];
但是,当我使用UIWebView进行呼叫时,系统会发出警报。我想知道用户选择了哪个按钮索引。我不知道如何检索用户在警报中选择的选项的索引

使用以下代码

仅适用于iOS10+

您可以在
UIWebViewDelegate
中检测调用:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    if ([request.URL.absoluteString hasPrefix:@"tel:"]) {
        // make a call

        // this method is available in iOS10
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber] 
                                           options:nil 
                                           completionHandler:^(BOOL success) {
            // if success is NO, user tap cancel button, or other
            NSLog(@"%d", success);
        }];

        return NO; // the default view will not show
    }
    return YES;
}
设置
UIWebView

UIWebView *webV= [[UIWebView alloc] init];
webV.delegate = self;
NSURLRequest *request = [NSURLRequest requestWithURL: [NSURL URLWithString:@"tel:1834563578"]];
[webV loadRequest: request];
这样,您就知道点击了哪个按钮
completionHandler

中的
success
上,无法理解您的问题您无法理解
UIAlertView
UIWebView
处理。如果要检查
UIAlertView
的结果,请使用
UIAlertView
,不要在webview中加载URL。当我使用webview进行呼叫时,系统将显示alertView。我想知道我点击了哪个按钮索引。请原谅我的迟到,您的答案非常理想,但是,如果我自定义警报视图和操作处理程序,我怎么打电话呢。如果我使用系统的警报视图,当我点击第二个按钮时,呼叫将开始。好的,这就是问题所在!!!!忘记拨打电话将提醒Another提醒。在iOS 10中,
[[UIApplication sharedApplication]openURL:options:completionHandler:]将调用
completionHandler
。谢谢,好像这是唯一的方法。
UIWebView *webV= [[UIWebView alloc] init];
webV.delegate = self;
NSURLRequest *request = [NSURLRequest requestWithURL: [NSURL URLWithString:@"tel:1834563578"]];
[webV loadRequest: request];