Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tabbar's viewcontroller gets reload while changing the orientation, in iOS 8

I have a UITabBarController which has few tabs. When I change orientation of the app, in iOS 8, All of it's viewController's viewDidLoad get called. This is not happening when I run the app in iOS 7.

Is it any new functionality of iOS 8 that reload UITabBarController on orientation change? If so How can I prevent my Tabbar to reload it's view controller.

like image 353
Bhupesh Avatar asked Nov 19 '14 12:11

Bhupesh


1 Answers

I had the same problem. I noticed that on iOS8 when the orientation of the device is changing viewWillTransitionToSize:withTransitionCoordinator: is getting called on UITabBarController, and UITabBarController calls viewDidLoad method of any viewcontroller that has not been loaded yet.

For now,in my UITabBarController subclass I override this method to not call [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator].

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
    //Do not call [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
    NSLog(@"Device orinetation changed");
}
like image 66
Parul Garg Avatar answered Nov 08 '22 18:11

Parul Garg