2014-03-13 85 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