【问题标题】:Pop UITableViewCell subview over entire screen在整个屏幕上弹出 UITableViewCell 子视图
【发布时间】:2014-07-28 00:23:49
【问题描述】:

我有一个 tableView,每行都有一个 UIWebView

当 webView 被点击时,我希望它只是展开并占据整个屏幕。

但是,存在一些问题,我不确定是哪一个造成了干扰。首先我尝试了这样的事情:

webView.frame = self.view.bounds;
webview.bounds = self.view.bounds;
cell.clipsToBounds = NO;
webView.clipsToBounds = NO;

但是,webView 似乎无法超越单元格,无法扩展到适当的宽度并且通常无法正常工作。我也想过操纵单元格的高度,但似乎比应该的要麻烦。

所以基本上,我想将此 webView 移动到堆栈的顶部并更改其帧大小。

否则我可能只是实例化一个新的 webView,这似乎是一种浪费。有任何想法吗?谢谢

【问题讨论】:

    标签: ios uitableview uiwebview


    【解决方案1】:

    不要更改网络视图的框架。使用约束(或至少顶部和底部)将 web 视图绑定到单元格的所有四个侧面,当您点击单元格并被选中时,使用 heightForRowAtIndexPath 中的 indexPathForSelectedRow 属性使该单元格尽可能大表格视图。

    -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
        if ([[tableView indexPathForSelectedRow] isEqual:indexPath]) {
            return tableView.frame.size.height;
        }else{
            return 44;
        }
    }
    
    
    
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
        [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
        [tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
    }
    

    【讨论】:

      【解决方案2】:

      我不知道您为什么要将 WebView 放在单元格中。我不是专家,但每次滚动时不会重新创建 webview 吗?

      您可以使用SVWebViewController 并将以下代码放入您的 didselectrowatindexpath 以模态显示它。

      SVModalWebViewController *webViewController = [[SVModalWebViewController alloc] initWithAddress:@"http://google.com"];
      [self presentViewController:webViewController animated:YES completion:NULL];
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-06-29
        • 2012-01-31
        • 1970-01-01
        • 1970-01-01
        • 2020-12-11
        相关资源
        最近更新 更多