I have a UISplitViewController with a separate view controller for compact width. The master view controller shows a table view with a grouped style. Regular size class is insetGrouped and compact is grouped.
The view controllers have two paths, compact and regular width, but the only differences between the two are the table view style. The classes are the same as is the table view content.
I have to present a modal with a table view controller inside that needs to adapt to the size class. Before the modal is presented, I instantiate the right view controller for the current size class, however if the size class changes during presentation, the table view style doesn't change accordingly.
Is there a better way to handle the user changing the size class? Or just a general way to use a UISplitViewController and UITableView.Style with different size classes?
Many thanks for any solutions.
The view controllers have two paths, compact and regular width, but the only differences between the two are the table view style. The classes are the same as is the table view content.
I have to present a modal with a table view controller inside that needs to adapt to the size class. Before the modal is presented, I instantiate the right view controller for the current size class, however if the size class changes during presentation, the table view style doesn't change accordingly.
Is there a better way to handle the user changing the size class? Or just a general way to use a UISplitViewController and UITableView.Style with different size classes?
Many thanks for any solutions.
UITableView does not support changing its style once created, so you would need to recreate the entire table view to switch to a new style.
However, the new UICollectionView list API introduced in iOS 14 does support dynamically changing the appearance of the list at any time (and you can even create a list with different appearances for different sections). This is the recommended approach for new code. Check out the WWDC video for an introduction: https://developer.apple.com/videos/play/wwdc2020/10026/
However, the new UICollectionView list API introduced in iOS 14 does support dynamically changing the appearance of the list at any time (and you can even create a list with different appearances for different sections). This is the recommended approach for new code. Check out the WWDC video for an introduction: https://developer.apple.com/videos/play/wwdc2020/10026/