IOS - how to handle orientation changes in user table cells

I have subclassed UITableViewCell to create a custom cell for tableView. I am adding text and images to the contents of cellView.

Everything looks great in landscape mode (iPad), but not so much when I turn to the portrait. Where is the best way to handle orientation changes so that all the cells in the table can move content in their contentView? Am I putting this code in a TableViewController or in a subclass of UITableViewCell?

+3
source share
1 answer

You can play back using your autoresizingMask function of your cellular views to see that perhaps the correct result can be achieved automatically. If this does not work, in your tableView willAnimateRotationToInterfaceOrientation you can do:

NSArray* visibleCells = [tableView indexPathsForVisibleRows];
[self.tableView reloadRowsAtIndexPaths:visibleCells withRowAnimation:NO];
+3
source

Source: https://habr.com/ru/post/1766865/


All Articles