Suppose I want to achieve Pinterest's pin page, like this one:
This is my approach:
- make a
UICollectionViewController
, pin's page is aUICollectionViewCell
- cell is make of two components: pin info child vc && waterfall child vc
Then comes the problem: How can I reuse child view controller?
Some pseudo code:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
Pin *pin = self.dataSource[indexPath.row];
// i have to create a new childVC, based on different indexPath.
UITableViewController *pinInfoViewController = [[pinInfoViewController alloc] initWithPin:pin];
[cell updatePinViewWithPin:pin];
[self addChildViewController:pinInfoViewController];
// Add waterfall view controller
}
Every time this method is called, a new child view controller will be created, is it ok, or how to improve it?
UICollectionViewController
, right? so a fat controller is born. – Contentment