Search code examples
iosipaduisplitviewcontrolleruipopovercontroller

UISpliViewController DetailView disappears after rotation


I have a issue with the UIViewController, please first read before you answer, it is more complicated than it seems. Without Changing the super UIViewController rotation works without problems!

I have a UISplitViewController in Portrait orientation, than i klick on the Button to show the UIPopoverController Popover shown now i change the UIViewController from UISplitViewC to UITableViewC tableview Now i rotate the iPad to Landscape orientation tableview landscape And finally switch back to the SpliViewController! splitviewcontroller landscape As you can see, the MasterViewController isn't showed and the NavigationItem doesn't disappear.

That brings me to the assumption that the delegate function of the splitview aren't called on the rotation of the UITableViewController (no surprise)

How can i handle this issue?

Delegate functions

- (void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc {

//debug_NSLog(@"Entering portrait, showing the button: %@", [aViewController class]);
        barButtonItem.title = @"Akten";
        [self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
        [self setMasterPopover: pc];
}


// Called when the view is shown again in the split view, invalidating the button and popover controller.
- (void)splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {

        //debug_NSLog(@"Entering landscape, hiding the button: %@", [aViewController class]);
        [self.navigationItem setLeftBarButtonItem:nil animated:NO];
        [self setMasterPopover: nil];
    }

Thanks for your Help!


Solution

  • It is too long ago but as long as I can remember it was something like here stackoverflow.com/questions/4649617/…
    You master view controller needs to implement receive the splitview delegate and forward it to the splitview even if it is not visible.

    No guarantee, like I said, long time ago