iphone - 如何在NavigationController中推送WebView

标签 iphone objective-c cocoa-touch

我想在选择表格单元格时显示网页 View

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  [uiWebView loadRequest:[NSURL URLWithString:@"http://www.google.com"]];

  [self.navigationController pushNavigationItem:uiWebView animated:YES];
}

日志

-[UINavigationController pushNavigationItem:animated:]: unrecognized selector sent to instance

最佳答案

上面的代码不起作用,也有一些泄漏。 -

这是修改后的版本。

UIViewController *webViewController = [[[UIViewController alloc] 
    init] autorelease];

UIWebView *uiWebView = [[[UIWebView alloc] 
    initWithFrame: CGRectMake(0,0,320,480)] autorelease];
[uiWebView loadRequest:[NSURLRequest 
    requestWithURL:[NSURL URLWithString:@"http://www.google.com"]]];

[webViewController.view addSubview: uiWebView];

[self.navigationController 
    pushViewController:webViewController animated:YES];

关于iphone - 如何在NavigationController中推送WebView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1736625/

相关文章:

objective-c - 可以直接在同一个类的实例方法中访问实例变量来读取它们的值吗?

objective-c - 诊断错误 : "release sent to deallocated object"

iphone - 全双工在线音频 session

iphone - 触摸速度

ios - 当使用 "share"功能时,在标题中输入什么来包含用户的新分数?

iphone - 添加和删​​除键盘

iphone - 停止快速调用 webViewDidFinishLoad

iphone - 触摸时UISearchBar崩溃

iphone - 使用 IB 将分段控件添加到导航栏

android - 使用加速度计计算速度