Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在xamarin ios中从UIAlertController创建调用对话框_Ios_Xamarin_Xamarin.ios - Fatal编程技术网

如何在xamarin ios中从UIAlertController创建调用对话框

如何在xamarin ios中从UIAlertController创建调用对话框,ios,xamarin,xamarin.ios,Ios,Xamarin,Xamarin.ios,嗨,这是xamarin的IOS开发的新手 我想从UIAlertController拨打电话。下面是我试图用UIAlertController打电话的代码,但我不明白出了什么问题 var title = "Call"; var message = "1234567788"; var alertCotroller = UIAlertController.Create (title, message, UIAlertControllerStyle.Alert); //

嗨,这是xamarin的IOS开发的新手

我想从
UIAlertController
拨打电话。下面是我试图用
UIAlertController
打电话的代码,但我不明白出了什么问题

   var title = "Call";
    var message = "1234567788";   

    var alertCotroller = UIAlertController.Create (title, message, UIAlertControllerStyle.Alert);

// Create the actions.
 alertCotroller.AddAction(UIAlertAction.Create (cancelButtonTitle, UIAlertActionStyle.Cancel, alertAction =>
 Console.WriteLine ("The 'Okay/Cancel' alert's cancel action occured."));

alertCotroller.AddAction(UIAlertAction.Create ("Call", UIAlertActionStyle.Default, alertAction =>UIApplication.SharedApplication.OpenUrl(new NSUrl("tel:"+message)) ));    

PresentViewController (alertCotroller, true, null);


我只想使用
UIAlertController

呼叫消息号码,不可能在模拟器上测试电话呼叫

如果您在真实设备中进行测试。 试试这个:

UIApplication.SharedApplication.OpenUrl(new NSUrl("tel://" + message));
如果要提示用户而不是直接呼叫,可以使用:

UIApplication.SharedApplication.OpenUrl(new NSUrl("telprompt://" + message));

谢谢你的rply。我可以在emulator中查看调用,以便了解它如何显示给最终用户“tel://”这是req还是仅“tel:”还有一件事我对“UIAlertController”和“UIAlertView”有点混淆,我使用的是哪一个?iOS 8中不推荐使用UIAlertView。建议使用UIAlertController。