开发者

iOS - how to handle orientation changes in custom table cells

开发者 https://www.devze.com 2023-01-17 15:55 出处:网络
I have subclassed UITableViewCell to make a custom cell for a tableView. I add text and 开发者_如何学Cimages to the cell\'s contentView.

I have subclassed UITableViewCell to make a custom cell for a tableView. I add text and 开发者_如何学Cimages to the cell's contentView.

Everything looks great in landscape mode (iPad), but no so much when I rotate to portrait. Where is the best place to handle orientation changes so that all the table cells can reposition the contents in its contentView? Do I put this code in the TableViewController or in the UITableViewCell subclass?


You can play with autoresizingMask of your cell's views to see that maybe the proper result can be achieved automatically. If that doesn't work out, in your tableView's willAnimateRotationToInterfaceOrientation you can do:

NSArray* visibleCells = [tableView indexPathsForVisibleRows];
[self.tableView reloadRowsAtIndexPaths:visibleCells withRowAnimation:NO];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号