The table control gets a reboot when the orientation changes, in iOS 8

I have a UITabBarController that has several tabs. When I change the orientation of the application, in iOS 8, all of its viewController viewDidLoad is called. This does not happen when I launch the application in iOS 7.

Will the new iOS 8 functionality reload the UITabBarController when the orientation changes? If so, how can I prevent my Tabbar from restarting the view controller.

+6
source share
2 answers

Parul Garg is faithful and I experienced the same problem.

Remember that you will need to manually call your orientation change methods as soon as you enable viewWillTransitionToSize .

Each call to the orientation change method calls this method and the method in the tab class.

The solution is to use manual calls as follows:

 -(void) viewWillTransitionToSize:(CGSize)sizewithTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { //[super viewWillTransitionToSize:sizewithTransitionCoordinator:coordinator]; UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; UIInterfaceOrientation toInterfaceOrientation = orientation; if ([self.selectedViewController isKindOfClass:[UINavigationController class]]) { UINavigationController *navCtrl = (UINavigationController*)self.selectedViewController; UIViewController* NavSubController = [[navCtrl viewControllers] lastObject]; [NavSubController willRotateToInterfaceOrientation:toInterfaceOrientation duration:0.0]; } } 
+2
source

I had the same problem. I noticed that on iOS8, when the deviceโ€™s orientation changes viewWillTransitionToSize: withTransitionCoordinator: gets called in the UITabBarController, and the UITabBarController calls the viewDidLoad method of any view manager that is not already loaded.

Currently, in my subclass of UITabBarController, I override this method so as not to 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"); } 
+4
source

Source: https://habr.com/ru/post/978398/


All Articles