bfeher / BFPaperTabBarController

iOS UITabBar (controller) inspired by Google's Paper Material Design.
MIT License
342 stars 46 forks source link

Registering an observer in viewWillAppear #8

Closed Maguszin closed 10 years ago

Maguszin commented 10 years ago

If i try to present a new viewController from the tabBar the observer is removed when the viewWillDiappear method is called, the next time i try to present a viewController the app will crash because it will try to remove a observer that is no longer registered.

Would not it be better register an observer in the viewWillAppear method?

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    // Set up tab bar for KVO on its 'hidden' key:
    [self.tabBar addObserver:self forKeyPath:BFPaperTabBarControllerKVOKeyPath_hidden options:0 context:BFPaperTabBarControllerContext];
}
bfeher commented 10 years ago

Thanks @Maguszin! You are absolutely right! In fact I thought that's where it was! I guess this is byproduct of working on this in the morning before I go to work without coffee.

Sorry, a fix is on its way now.

bfeher commented 10 years ago

Ok I just pushed version 1.4.5 which moved the KVO registration to viewWillAppear. Thanks again and let me know if you find more bugs! :)

Maguszin commented 10 years ago

Thanks @bfeher :)