Search code examples
xcodeipaduiviewcontrolleruipopovercontrolleruitoolbar

iPad - Section of screen no longer receiving touch events after full screen modal view controller dismissed on iPad


I have toolbar at the top of the (full screen) main view in my iPad. The toolbar has a barButtonItem that when pressed, shows a popover.

In the popover, I have a UIButton that when pressed, tells the delegate (the main view controller) to dismiss the popover and show a full page modal view.

This all works fine.

When I dismiss the modal view, the area of the screen the popover occupied - including the main view and toolbar buttons - is no longer responding to touch events.

This problem corrects itself if I rotate the device and only occurs in Landscape mode.

Any suggestions?

Update: This bug does not happen when running in the Simulator, only on an actual iPad.

The delegate method I have to dismiss the full screen modal view..

- (void)fullScreenViewControllerDidFinish:(FullScreenWebViewController *)fullScreenWebView {
    [self dismissViewControllerAnimated:YES completion:^{
        [self setFullScreenWVC:nil];
        [[self view] setNeedsLayout]; //Does't fix the issue
    }];
}

Update: Using Instruments, I've gotten the iPad to show me how it's laying out subviews. It looks like it thinks the iPad is in Portrait when the modal view is dismissed but the device is obviously in landscape.

enter image description here


Solution

  • I fixed the problem.

    I was using

    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; 
    

    instead of

    UIDeviceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
    

    The iPad wasn't getting the right orientation for some reason.

    Thanks for your help.