Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/269.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
C# iOS手机链接打开信息应用程序而不是拨打电话号码_C#_Ios_Xamarin - Fatal编程技术网

C# iOS手机链接打开信息应用程序而不是拨打电话号码

C# iOS手机链接打开信息应用程序而不是拨打电话号码,c#,ios,xamarin,C#,Ios,Xamarin,我需要文本视图中的电话号码,以便在单击时拨打该电话号码: 我面临的问题是,当点击链接时,消息应用程序正在打开。我在iOS 12中尝试了下面的代码,效果如预期,但当我在iOS 13和14上尝试时,消息应用程序打开,而不是使用“电话拨号器应用程序”拨打电话 暂定1: textView.Editable = false; textView.DataDetectorTypes = UIDataDetectorType.PhoneNumber; 暂定2: var phoneNumberLink = n

我需要文本视图中的电话号码,以便在单击时拨打该电话号码:

我面临的问题是,当点击链接时,消息应用程序正在打开。我在iOS 12中尝试了下面的代码,效果如预期,但当我在iOS 13和14上尝试时,消息应用程序打开,而不是使用“电话拨号器应用程序”拨打电话

暂定1:

textView.Editable = false;
textView.DataDetectorTypes = UIDataDetectorType.PhoneNumber;
暂定2:

var phoneNumberLink = new Dictionary<string, string>(){ { "(855) 757-7328","tel:8557577328" } }
textView.Editable = false;
textView.SetAttributedTextForLinks("Please call us at (855) 757-7328", phoneNumberLink);
var phoneNumberLink=newdictionary(){{(855)757-7328”,“电话:8557577328}
textView.Editable=false;
SetAttributedTextForLinks(“请致电(855)757-7328”,电话号码链接);
如前所述

打开拨号器的正确方法是

   telprompt://0123456789

确保没有空格。

实际上,
telpromt://0123456789
也不起作用。我必须拦截与URL的交互,建议的
ShouldInteractWithUrl
不起作用(
ShouldInteractWithUrl
未被触发或调用),因此我必须使用
allowurinteraction
。代码如下所示:

var description = new KiteEmbeddedLinkTextView()
{
    Editable = false,
    DataDetectorTypes = UIDataDetectorType.PhoneNumber,
    Text = message.MessageText
};
description.AllowUrlInteraction += AllowUrlInteraction;


private bool AllowUrlInteraction(UITextView textView, NSUrl url, NSRange characterRange, UITextItemInteraction interaction)
{
    UIApplication.SharedApplication.OpenUrl(url);
    return false;
}
出于某种原因,除了这个,以前的选择都不适合我

见:

看,我明白了,在找到这个讨论之后,我实际上只是在尝试:但是说实话,“DataDetectorType”不能满足我的需要,这真是令人恼火(我不得不添加一些东西来设置SetAttributedTextForLinks。虽然DataDetectorType只是一行简单的代码……无论如何……非常感谢!很高兴提供帮助!)