IOS Custom Table Cell does not Automatically Resize Width for Orientation Change

ort11 picture ort11 · May 13, 2013 · Viewed 10.9k times · Source

Have a custom table cell with it's own .XIB and .h and .m. Nothing too fancy. When the device rotates, the cell width does not change. The tables cell for index path is called, but width is not changes (say from portrait to landscape). What would be preventing this?

Don't want to hand set the frame size.

Will post code if need to, but maybe we can answer with out code on this one.

Even if starting the app in landscape also does not set the larger width for the cell.

[Addition]

Also does not work with non-custom cells.

self.tableViewSelection.autoresizesSubviews = true;
self.tableViewSelection.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.view.autoresizesSubviews = true;

XIB for the table has the resizing seemed to be setup correctly (non-IOS6 Support).

Answer

Bruno Lemos picture Bruno Lemos · Sep 4, 2015

If you are overriding the layoutSubviews or another method, don't forget to call it's super:

override func layoutSubviews() {
    //...

    super.layoutSubviews()
}

Not doing this will result in the problem you are facing.