Reputation: 7004
I'm trying to implement iPhone and iPad versions gracefully. They're essentially the same controller, but one the iPhone presents in a single column tableView and the iPad in a multi-column collectionView.
Here are the options I thought of:
One ViewController that asks for a different DataSource and different Delegate for tableView vs collectionView. I haven't thought this option all the way through. It does seem like it might get overly complicated.
One baseViewController and then 2 subclasses, one with a tableView and one with a collectionView. Similar to option #1 but using subclasses. Option #1 is cleaner, but this would be easier to implement.
Just use a collectionView for both, but use different UICollectionViewFlowLayouts. This was the last option I thought of and seems like by far the best option, but I'm wondering if there's a reason why #1 or #2 might be better.
Upvotes: 3
Views: 784
Reputation: 7004
So I ended up going with 1 UICollectionView, and IMO it works great.
I had to write conditionals for only 3 parts:
collectionView:layout:sizeForItemAtIndexPath:
layoutSubviews
of the UICollectionViewCell
Being able to use the same UICollectionViewCell
was a really big plus since I am implementing a number of buttons within the cell, and I didn't have to replicate delegates for exactly similar logic in a UICollectionViewCell
AND a UITableViewCell
.
Upvotes: 1