objective-c将解析后的html元素转换为UITableViewCell中的链接



我在这里学习了教程:http://www.raywenderlich.com/14172/how-to-parse-html-on-ios

其中一个挑战是:"当你点击每一行时,让手机打开Safari到该教程或贡献者的URL?"

如何使动态解析的数据成为每个UITableViewCell的链接?在浏览器中打开和在应用程序中打开在代码上有什么区别?

提前谢谢。

要在Safari中打开URL,您需要:1.使用URL创建字符串。

NSString *urlString =@"http://www.google.com";

2.用UIApplication 的这种方法打开它

[[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlString]];

若你们想打开应用程序内部的链接,你们需要。1.创建WebView并将其设置为委托(如果要控制加载过程,则为可选)。

UIWebView *webView =[[UIWebView alloc] initWithFrame:CGRectInset(self.view.frame, 10, 10)];

2.创建URL请求

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]];

3.添加WebView作为子视图

[self.view addSubview:web view];

4.加载您请求的

[webView loadRequest:request];

尝试

[[UIApplication sharedApplication] openURL:tutorialURL];

最新更新