2014-03-13 86 views
0

我使用UIWebView拨打电话时,我该如何自定义警报视图拨打电话,目前

NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel://123456789"]; 
[self.callWebview loadRequest:[NSURLRequest requestWithURL:telURL]]; 

当我触摸一个按钮来进行呼叫,一个UIAlertView出现,并要求与确认title 123456789

如何更改标题和消息?

谢谢。

+0

? –

+0

不完全,它是一个'UIAlertView',当我尝试以编程方式拨打电话时,它会自动出现。但是,我无法访问它。 –

回答

2

不要使用UIWebView,只会向用户询问他/她是否想要打电话给UIAlertViewtel:方案中也没有//,所以tel:123456789是正确的。

然后只需通过[[UIApplication sharedApplication] openURL:telURL]打开tel:网址。

而且不要忘了检查用户设备是否可以拨打电话:

NSURL *telURL = [NSURL URLWithString:@"tel:123456789"]; 

if ([[UIApplication sharedApplication] canOpenURL:telURL]) { 
// Present the user with the dialog to start the call 
} else { 
// inform the user that he/she can't call numbers from their device. 
} 
要更改alertView标题和消息
+0

谢谢,但我认为使用'tel'或'telprompt'并不是Apple推荐的,即使它可行。回到问题中,我做了你所说的,我在问题中提到的'AlertView'出现在我的自定义'AlertView'的顶部。似乎喜欢iOS 7强制它这样。 –

+0

Apple只记录'tel'。 'telprompt'没有被Apple记录或引用,这意味着你不应该使用它,因为它可以在任何时候被Apple删除。如果您使用'tel'拨号,将不会显示对话框。只是不要使用'UIWebView',只需调用'[[UIApplication sharedApplication] openURL:telURL]' – rckoenes