如何从 iphone 应用程序查询调用 safari 中的 weblink
我正在解析 xml 文件以获取电话号码值(aMarker.web= weblink)。其中标记是我在解析器控制器中获取的 xml 文件中的属性。我可以使用以下方法在按钮标题上设置此 webLink 字符串,
[w_Bcard setTitle:[NSString stringWithFormat:@"%@",aMarker.web] forState:UIControlStateNormal];
但通过点击按钮我无法拨打该号码。请参阅我的代码
- (IBAction)weblink_BcardVeiw
{
NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
marker *aMarker = (marker *)[appDelegate.markers objectAtIndex:selectedIndexPath.row];
for (int selectedIndexPath = 0; selectedIndexPath < [appDelegate.markers count]; selectedIndexPath++)
{
NSString *utfString = [NSString stringWithFormat:@"%@",aMarker.web];
NSURL *url = [NSURL URLWithString:utfString];
[[UIApplication sharedApplication] openURL:url];
NSLog(@"%@",url);
}
[self.tableView deselectRowAtIndexPath:selectedIndexPath animated:YES];
通过 NSloging m 获取相应的 url,但无法在 safari 中打开此 url。我应该在哪里更正上面的代码??? 我还想通过传递动态字符串 aMarker.email 来调用邮件应用程序。您也可以建议该代码吗?
I am parsing xml file to get phone number values (aMarker.web= weblink). Where marker is attributes in xml file which I am fetching in my parser controller. I am able to set this webLink string on Button title by using
[w_Bcard setTitle:[NSString stringWithFormat:@"%@",aMarker.web] forState:UIControlStateNormal];
But by tapping button I am not able to call the number. See my code
- (IBAction)weblink_BcardVeiw
{
NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
marker *aMarker = (marker *)[appDelegate.markers objectAtIndex:selectedIndexPath.row];
for (int selectedIndexPath = 0; selectedIndexPath < [appDelegate.markers count]; selectedIndexPath++)
{
NSString *utfString = [NSString stringWithFormat:@"%@",aMarker.web];
NSURL *url = [NSURL URLWithString:utfString];
[[UIApplication sharedApplication] openURL:url];
NSLog(@"%@",url);
}
[self.tableView deselectRowAtIndexPath:selectedIndexPath animated:YES];
By NSloging m getting respective url but not able to open this url in safari. Where should I correct the above code???
I also want to call mail application by passing dynamic string aMarker.email. Can you suggest that code also.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将使用数据检测器。例如,您可能会这样做:
我在某些代码中做了类似的事情,我创建了一个替换 UITextView,它可以处理属性文本(样式)并检测电话号码、链接和地址等内容。基本上你想要的是数据检测器。
You would use a data detector. For instance, you might do something like this:
I do something like this in some code where I create a replacement UITextView which can handle attributed text (styled) and detect things like phone numbers, links and addresses. Basically what you want are data detectors.