zoukankan      html  css  js  c++  java
  • iOS7's subview trimmed if out of parent view bounds

    http://stackoverflow.com/questions/18868869/ios7s-subview-trimmed-if-out-of-parent-view-bounds

    It's because iOS 7 introduced some changes to the view hierarchy of UITableViewCells.

    It used to be UITableViewCell view -> contentView.

    Now it's more like UITableViewCell view -> scrollView -> contentView.

    The solution is to set clipsToBounds = NO on the scrollView (which is set to YES by default). And the way to achieve that is through the superview property.

    So basically in iOS6 and prior, to allow content to spill out of the cell bounds, you would do:

    self.clipsToBounds = NO; //cell's view
    self.contentView.clipsToBounds = NO; //contentView
    In iOS7 you have to also prevent the scrollview from not clipping so you'd do something like:

    self.clipsToBounds = NO; //cell's view
    self.contentView.clipsToBounds = NO; //contentView
    self.contentView.superview.clipsToBounds = NO; //scrollView
    And the backwards compatible solution I use is:

    self.clipsToBounds = NO;
    self.contentView.clipsToBounds = NO;
    if ([self.contentView.superview isKindOfClass:[NSClassFromString(@"UITableViewCellScrollView") class]]) self.contentView.superview.clipsToBounds = NO;
    Keep in mind this is Hacky™ and if the view hierarchy changes again in iOS 8, you might be in trouble. Unfortunately it seems Apple doesn't want us to spill content out of UITableViewCells so AFAIK this is the only workable solution.

  • 相关阅读:
    云计算安全之传统安全业务连续性和灾难恢复
    如何降低云应用程序的风险并管理其保障措施
    映射函数
    numpy用法
    dataframe基础
    list用法
    可视化基础
    pycharm使用技巧
    时间用法
    merge()函数
  • 原文地址:https://www.cnblogs.com/qike/p/5395672.html
Copyright © 2011-2022 走看看