简体   繁体   中英

How to call a set phone number from a button click using Xamarin iOS

Hello I am working on a app that needs to call a certain phone number when the button is clicked i am using Xamarin iOS to do this here's my code:

using Foundation;
using System;
using System.CodeDom.Compiler;
using UIKit;

namespace appname
{
    partial class HomeView : UIViewController
    {

        public HomeView (IntPtr handle) : base (handle)
        {
            phonebutton.TouchUpInside += delegate {
                var url = new NSUrl("tel:12345678");
                UIApplication.SharedApplication.OpenUrl(url);
            };
        } 
    }
}

I am new to Xamarin iOS so any links of examples would be so amazing!

该代码对我来说似乎是正确的-您是否尝试过在设备上对其进行测试?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM