Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UINavigationController inside UIPopoverController 'Back' animations weird in Landscape

I'm stumped :-\

I have a legacy app in the store that I'm refreshing for iOS 8/9. It was written years ago (pre-ARC) and is a universal app for iPhone and iPad. Everything is now working apart from this ...

On iPad, there is a toolbar at the top of the screen from which I present UIPopoverControllers containing a UINavigationController containing some standard UITableViewController type screens you can drill down into.

In Portrait (and Portrait Upside Down) everything works as expected.

In Landscape however, pressing 'Back' (the standard back not a custom one) causes weird animations - the outgoing controller jumps outside the popover and rapidly slides offscreen (the direction being governed by which orientation the device is in) while the incoming controller simply appears instantly as soon as the outgoing controller jumps outside the popover. I had to use slow animations to determine this as at full speed it just looks like a huge glitch.

There's a short 20 second movie showing the defect here; Note what happens when tapping 'Locations' at 14 seconds in.

If, instead of a UIPopover, I present the VC stack as a form sheet, everything works as expected regardless of orientation. I've also tried the newer UIPopoverPresentationController and experienced the SAME problem, which surprised me a little.

This happens on both of the popovers I'm presenting (one from left of toolbar, one from right of toolbar) and they both have very different internals. The only common factor is that they have a UINavigationController inside a UIPopover.

I've used the view debugger to inspect the view hierarchy, but nothing seems out of the ordinary and I can't capture the view during the glitch no matter how slow I run the simulator so I suspect I'm seeing an internal issue with the popover or navigation controller.

Has anyone seen anything similar? I see this both on-device (iOS 8.4) and in Simulators for iOS 8 and 9.

For context, this project has no storyboards, rarely uses xibs and generally constructs the UI in code within loadView - it really is an old application...

Thanks for any pointers. Not sure how much any code will help here, but here's the presentation of the popover concerned;


LocationsViewController* locationsvc = [[LocationsViewController alloc] init];

UINavigationController *localNavigationController = [[UINavigationController alloc] initWithRootViewController:locationsvc];
localNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
[locationsvc release];

UIPopoverController* aPopover = [[UIPopoverController alloc] initWithContentViewController:localNavigationController];

aPopover.delegate = self;
aPopover.backgroundColor = [UIColor colorWithWhite:0 alpha:0.9];
self.locationPopoverController = aPopover;        
[aPopover release];
[localNavigationController release];

[locationPopoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

I get the same defect with the following, new flavour code;


UINavigationController *destNav = [[UINavigationController alloc] initWithRootViewController:locationsvc];

locationsvc.preferredContentSize = CGSizeMake(320,280);

UIPopoverPresentationController *newPresentationController;
destNav.modalPresentationStyle = UIModalPresentationPopover;
newPresentationController = destNav.popoverPresentationController;
newPresentationController.barButtonItem = sender;
destNav.navigationBarHidden = NO;
[self presentViewController:destNav animated:YES completion:nil];

And the same problem shows when I use UIModalPresentationPageSheet but NOT when I use UIModalPresentationFormSheet.

like image 312
Roger Avatar asked Oct 25 '15 10:10

Roger


1 Answers

I had the same issue. The issue was fixed after I added support of landscape orientation to view controllers inside the navigation controller.

- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}
like image 120
Maxim Malygin Avatar answered Nov 20 '22 18:11

Maxim Malygin