【问题标题】:UIWebView inside UITableViewCell load content everytime I scroll每次滚动时,UITableViewCell 中的 UIWebView 都会加载内容
【发布时间】:2013-08-09 09:47:34
【问题描述】:

我正在使用 UIWebViewUITableView 中加载 Youtube 视频。一切正常,除了它加载每次我滚动表视图。我已阅读此问题 (UIWebView in UITableView reloads everytime I scroll. How do I prevent it from reloading?) 但尚未解决。

我的代码:

NSString *videoUrl =[NSString stringWithFormat:@"src=\"http://www.youtube.com/embed/%@\"",     videoId];
            NSString *htmlString =[NSString stringWithFormat:@"<iframe width=\"273\" height=\"152\" %@ frameborder=\"0\" allowfullscreen></iframe>", videoUrl];
            NSLog(@"%@", htmlString);
            cell.myWebview.scrollView.scrollEnabled = NO;
            cell.myWebview.scrollView.bounces = NO;
            [cell.myWebview loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"http://www.youtube.com"]];
            [cell.contentView addSubview:cell.myWebview];

【问题讨论】:

    标签: ios uitableview uiwebview


    【解决方案1】:

    你在打电话

    [cell.myWebview loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"http://www.youtube.com"]];
    

    每次,这就是原因。也许你可以在另一个地方加载 webview,然后在 cellForRowIndexPath 方法中加载它,就像这样:

    cell.myWeview = "....already loaded webview"
    

    【讨论】:

    • 你能给我代码吗?对不起,我还是不明白:)。
    猜你喜欢
    • 2013-06-16
    • 1970-01-01
    • 2020-02-24
    • 1970-01-01
    • 1970-01-01
    • 2012-12-16
    • 1970-01-01
    • 1970-01-01
    • 2014-10-12
    相关资源
    最近更新 更多