CustomTableCellView's implementation of -layoutSubviews needs to call super , NSInternalInconsistencyException

后端 未结 2 1302
离开以前
离开以前 2021-01-18 02:03

On using autoLayout in custom cell for tableView xib, i am getting following error.

When running in iOS 6 simulator CustomCells\'s implementation o

相关标签:
2条回答
  • 2021-01-18 02:09
    layoutSubviews needs to call super
    

    Can be worked around on iOS6 by putting everything in your custom tableview cell in a container view. ie Create a new view to fill the cell then place controls etc inside that. Also make sure you set:

    [theContainerView setTranslatesAutoresizingMaskIntoConstraints:NO]; 
    

    for the container and subviews

    0 讨论(0)
  • 2021-01-18 02:11

    iOS 5.1 and earlier versions are not compatible with AutoLayout. It's only for iOS 6.0+.

    Assuming you're using storyboards, if you want to use AutoLayout but still preserve compatibility with iOS versions prior to 6.0, you'll need to create two targets: one for iOS 6 and another for iOS 5 (or earlier). For each, set a separate storyboard, one where AutoLayout is enabled (for iOS 6), and one where it is not (for iOS 5).

    Here's a StackOverflow thread for best practices with AutoLayout and backward-compatibility with iOS 5: Enabling auto layout in iOS 6 while remaining backwards compatible with iOS 5.

    In my experience, it's not worth the effort to use AutoLayout if you want backwards compatibility. If you're using storyboards, it's a maintenance headache to have 2 targets and 2 storyboards to synchronize. If you're not using storyboards, you'll need separate code for iOS 5 and iOS 6, which will take longer to test and update.

    0 讨论(0)
提交回复
热议问题