zoukankan      html  css  js  c++  java
  • iOS UITableviewWrapperView 和 automaticallyAdjustsScrollViewInsets属性

      关于在navigationController下面使用tableView在竖直方向会遇到frame的y值的困惑,
    会遇到视图控制器的这个属性:automaticallyAdjustsScrollViewInsets.
      apple的解释:
     

    A Boolean value that indicates whether the view controller should automatically adjust its scroll view insets.

     

    The default value of this property is YES, which allows the view controller to adjust its scroll view insets in response to the screen areas consumed by the status bar, navigation bar, and toolbar or tab bar. Set to NO if you want to manage scroll view inset adjustments yourself, such as when there is more than one scroll view in the view hierarchy.

     

      这是指示ViewController是否自动调整subview中的scrollView位置的布尔变量。
      此属性的默认值是YES,它使得视图控制器来调节响应的状态栏,导航栏占用的屏幕区域的scrollview,和toolbar或tabBar。,如果你要自己管理插入调整scrollView就设置为NO。

     在iOS7以下系统,UITableViewCell.superview就是UITableView,但在IOS7中,cell上面还多了一个UITableViewWrapperView,所以需要UITableViewCell.superview.superview获取UITableView
     
    iOS 获取操作系统的版本

     1 [[[UIDevice currentDevice] systemVersion] floatValue] 

     
     1 UITableView *tableView;
     2 
     3      float Version=[[[UIDevice currentDevice] systemVersion] floatValue];
     4 
     5     if(Version>=7.0)
     6 
     7     {
     8 
     9        tableView = (UITableView *)self.superview.superview;
    10 
    11     }
    12 
    13     else
    14 
    15     {
    16 
    17         tableView=(UITableView *)self.superview;
    18 
    19     }
    20 
    21      NSIndexPath *indexPath= [tableView indexPathForCell:self];
    22 
    23     indexPath = [NSIndexPath indexPathForRow:kImage1IndexinSection:indexPath.row];
    24 
    25  

    但是今天所做的项目里用到了tabbarController中一个VC的childVC中使用tableView时候,在切换tabbar的VC时,ChildVC的table会掉64(navigationBar的高度),设置automaticallyAdjustsScrollViewInsets 也无效,

    所以只好拿到UITableviewWrapperView强行设置frame:

    1 for (UIView *subview in tableView.subviews)
    2 {
    3     if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewWrapperView"])
    4     {
    5         subview.frame = CGRectMake(0, 0, tableView.bounds.size.width, tableView.bounds.size.height);
    6     }
    7 }

    应该是automaticallyAdjustsScrollViewInsets的问题,以后研究

    参考链接: http://stackoverflow.com/questions/27671324/uitableviewwrapperview-and-uitableview-size-differs-with-autolayout

  • 相关阅读:
    Python Excel 合并 去重
    前端 导出为Excel 数据源为table表格 table中的字段7-1变成了7月1号解决
    SpreadJS 基本信息
    Python 模拟向四面八方拖动
    Python 淘宝联盟-佣金设置 批量设置佣金和服务费
    Python 模拟鼠标滚轮 滚动页面
    评审恩仇录——我为什么愿意执行代码评审
    浅谈专有云MQ存储空间的清理机制
    三只松鼠:阿里云数据中台基座上的多渠道、多业态生长
    谈AK管理之基础篇
  • 原文地址:https://www.cnblogs.com/A--G/p/5149000.html
Copyright © 2011-2022 走看看