【发布时间】:2010-12-30 08:19:31
【问题描述】:
我创建了我的应用程序。我需要在 iPhone 中打开 URL,直接 safari 视图。
我的代码如下:
NSString *email = [NSString stringWithFormat:@"http://itunes.apple.com/us/album/music/id186152317?i=186153149&uo=4"];
email = [email stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSURL *url = [NSURL URLWithString:email];
if (![[UIApplication sharedApplication] openURL:url])
NSLog(@"%@%@",@"Failed to open url:",[url description]);
[super viewDidLoad];
但我的问题是,Safari 视图已打开。但是网址没有打开。它显示错误。错误是
无法打开页面 safari 无法打开页面,因为地址无效
但是网址是在浏览器中打开的。
有谁知道解决方案,使用 Objective C 在 iPhone 的 Safari 中打开此 URL?
【问题讨论】:
-
你最好尝试使用苹果文档中的 NSURLconnection。
标签: iphone