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).
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.
The cell will automatically be the same width as the table view. So what is not resizing might be the table view. You need to give it appropriate constraints (if using Autolayout, the default in iOS 6) or autoresizing mask (otherwise) so that it will resize in response to the top-level view resizing to compensate for device rotation.
I also faced this same issue while autoresizing custom cells on rotating. After fighting I got the solution as authorize cell.contentView, because I am adding my views as subview into cell.contentview.
I used following code and my code works fine :)
cell.contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With