我正在制作一款拥有大量文章的iPhone应用程序"用某些单词我想链接到其他"文章"。我需要在UITableViewCells中显示文章。
如果有办法在没有网络视图的情况下执行此操作,那就太棒了。
如果我需要使用网页视图,我应该制作<a href>
样式链接吗?如何让它跳转到文章而不创建一堆实际的html页面,只是让它让我的程序知道他们点击了那个链接,然后程序就会从plist或者其他东西找到合适的文章?
答案 0 :(得分:0)
我使用UIWebView
创建了一个测试演示,它运行正常。
创建两个HTML文件:home.html和first.html。
// home.html
Home page. <a href="first.html">first</a>
// first.html
First page. <a href="home.html">home</a>
//viewDidLoad
self.webView.delegate = self;
NSString *htmlFilePathString = [[NSBundle mainBundle] pathForResource:@"home" ofType:@"html"];
NSURL *htmlFileURL = [[NSURL alloc] initFileURLWithPath:htmlFilePathString];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:htmlFileURL];
[self.webView loadRequest:request];
// webView's delegate:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
return YES;
}