UISplitViewController not calling delegate methods while pushing new detailView

元气小坏坏 提交于 2019-12-11 01:02:26

问题


I setup a storyboard based on the Master-Detail Application, embed the detail view in a navigation controller, and add a new table view controller object which I will use as a second detail view controller.

I then push the new detail view controller with the following code (instead of a segue because I am pushing both a root view and a detail view controller at the same time. Only the detail view code is shown).

// Push the detailView view controller:
NewClass *newViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"test"];

newViewController.navigationItem.hidesBackButton = YES;
self.splitViewController.delegate                = newViewController;

[self.detailViewController pushViewController:newViewController animated:YES];

This works perfectly, EXCEPT that the splitView delegate methods are never called before or after the push. If I do this while in portrait mode, after it pushes the detailViewController, the button to drop down the masterView popover does not show up UNTIL I rotate to landscape mode and then back to portrait mode.

How can I cause the willHideViewController/willShowViewController split view controller delegate methods to be called or manually cause them to be called?


回答1:


So from what I found, it doesn't call the method because the orientation hasn't changed.

What you have to do is to pass the button from the presenting view controller since it's already tied to the popover like this:

if(self.navigationItem.leftBarButtonItem != nil) {
    newViewController.navigationItem.leftBarButtonItem = self.navigationItem.leftBarButtonItem;
}

// Push the newViewController


来源:https://stackoverflow.com/questions/7871037/uisplitviewcontroller-not-calling-delegate-methods-while-pushing-new-detailview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!