iphone - 从幻灯片 View 加载 UIWebView

标签 iphone ios objective-c uiwebview

我有一个看起来与此类似的 UIViewController

enter image description here

左侧是带有单元格的 TableViewController,右侧是 UIWebView。单击单元格后,我想加载一个唯一的 URL,具体取决于单击的是哪个单元格。

出于某种原因,当我单击单元格时,从未向 UIWebView 发送请求以加载 url。 UIWebViewUITableViewDelegate 都在同一个 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];
}

为什么这不起作用? UIWebViewUITableView 都是viewController 中的IBOutlets。点击被识别,这个 webView 加载请求在放入 viewDidLoad 函数时有效,但当相同的代码用于点击时没有任何反应。

如果它对你有帮助,我正在使用这个 github api https://github.com/mikefrederick/MFSideMenu

感谢您的帮助, 迈克

最佳答案

[webView loadRequest:request]; 行之后添加这一行 ...

[webView reload];

引用此文档... UIWebView_Class

例如:

[webView loadRequest: [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.co.in"]]];
[webView reload];

关于iphone - 从幻灯片 View 加载 UIWebView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16139942/

相关文章:

ios - Phonegap/Cordova Youtube在iOS上嵌入视频无法正常工作

iphone - iOS4 实现-[NSURLConnection sendAsynchronousRequest :queue:completionHandler:]?

ios - 苹果支付 Stripe : Using apple pay certificate not able build

ios - 关于在IOS中创建动态数据表的建议

ios - 几天后测试中的 iPhone 应用程序崩溃

iphone - 如何将用户设置值保存到 UISwitch?

iphone - 通过 iPhone SDK 确定东海岸当前使用的是 EST 还是 EDT

ios - 从结构模型填充 View 时的 nil 值

ios - Evernote -3000 错误,状态代码 201,阻止用户进行身份验证

ios - UItableVIew 可重用 Cell 在滚动后在随机单元格添加按钮?