Why didRotateFromInterfaceOrientation in the category cause problems with UISplitView?

I have a tab app with UISplitView on one of the tabs.

I am using UITabBarController + iAds and have a problem that the developer still could not solve.

Unfortunately, this is what my user interface looks like an iPad rotation:

enter image description hereenter image description here

The category is called from AppDelegate, and the following code is used to update the ad when the device is rotated:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { NSLog(@"Did rotate"); [self layoutBanner]; } 

As I understand it, this prevents the MasterViewController from working properly, but I don’t quite understand the principle of cascading method calls to figure out how to fix this problem.

+5
source share
1 answer

This Apple Developer Guide talks about the didRotateFromInterfaceOrientation method:

Subclasses can override this method to perform additional actions immediately after rotation.

...

Your implementation of this method should call super at some point during its execution.

My best guess is that some drawing operations in the view controller do not occur because you are not calling the superclass method from your implementation. Try fixing this as follows:

 - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; NSLog(@"Did rotate"); [self layoutBanner]; } 

UPDATE: In iOS 8, this method is deprecated and is no longer called when the device is rotated. Instead, you need to use the new method:

 - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; NSLog(@"Szie changed"); [self layoutBanner]; } 
+7
source

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


All Articles