我有一个UIViewController
看起来与此类似的。
左侧是TableViewController
带有单元格的a,右侧是a UIWebView
。单击单元格后,我想根据单击的单元格加载唯一的 URL。
UIWebView
由于某种原因,当我单击单元格时,永远不会向加载网址发送请求。theUIWebView
和 theUITableViewDelegate
都在同一个UIViewController
.
这是我的示例代码:
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSMutableURLRequest *request;
if (indexPath.row == 0) {
request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]];
}
else if (indexPath.row == 1) {
request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.yahoo.com/"]];
}
[webView loadRequest:request];
}
为什么这不起作用?theUIWebView
和 theUITableView
都IBOutlets
在viewController
. 点击被识别,并且这个webView
加载请求在放入viewDidLoad
函数时有效,但是当点击时使用相同的代码时没有任何反应。
如果它对你有帮助,我正在使用这个 github api https://github.com/mikefrederick/MFSideMenu
谢谢你的帮助,迈克