Skip to content

Instantly share code, notes, and snippets.

@radianttap
Created January 23, 2013 16:15
Show Gist options
  • Save radianttap/4608892 to your computer and use it in GitHub Desktop.
Save radianttap/4608892 to your computer and use it in GitHub Desktop.
Never initialize multiple UICollectionViewControllers with the same UICollectionViewLayout instance
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// this subclass defines itemsSize as {320, 88}
MyUICollectionViewFlowLayout *l = [[MyUICollectionViewFlowLayout alloc] init];
// initialize one subclass of UICollectionViewController
MainViewController *mvc = [[MainViewController alloc] initWithCollectionViewLayout:l];
// initialize another with same layout
// but inside this init method do:
// l.itemSize = CGSizeMake(320,44)
SecondViewController *novc = [[SecondViewController alloc] initWithCollectionViewLayout:l];
// that change 44 is also applied to MainViewController layout
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[mvc, novc];
self.window.rootViewController = self.tabBarController;
// in hindsight, this was really stupid thing to do, but it's an easy copy/paste error to do.
// grumpf.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment