gpt4 book ai didi

iphone - uibutton onclick 不调用/打开网页

转载 作者:行者123 更新时间:2023-12-03 20:29:01 25 4
gpt4 key购买 nike

我定义了两个按钮。其中一个单击时必须打开撰写邮件屏幕,而另一个单击时必须调用。我的定义如下。但是当按下按钮时,它也不会打开

-(IBAction) phoneButtonPressed:(id) sender{
NSString *phoneNumber = [[NSString alloc] initWithString:@"4216483330"];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
}

-(IBAction) mailButtonPressed:(id) sender{

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5435273f35383d362635263d353a1439353d387a243d20207a313021" rel="noreferrer noopener nofollow">[email protected]</a>?subject=ULS Library"]];
}

最佳答案

对于电话#,网址应以“tel:”为前缀,如下所示:

NSString *phoneNumber = [[NSString alloc] initWithString:@"tel:4216483330"];


对于邮件,问题是 url 字符串(在“ULS 库”中)中有一个空格,在将其提供给 NSURL 之前需要对其进行转义:

NSString *urlString = @"mailto:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e081938b818c898292819289818ea08d81898cce90899494ce858495" rel="noreferrer noopener nofollow">[email protected]</a>?subject=ULS Library";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[urlString
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];

请参阅Apple URL Scheme Reference .

关于iphone - uibutton onclick 不调用/打开网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4550930/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com