UISplitViewController不推送新的detailView时调用委托方法 [英] UISplitViewController not calling delegate methods while pushing new detailView

查看:118
本文介绍了UISplitViewController不推送新的detailView时调用委托方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置了基于Master-Detail应用程序的故事板,将详细视图嵌入到导航控制器中,并添加一个新的表视图控制器对象,我将用作第二个详细视图控制器。

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.

然后使用以下代码推动新的详细视图控制器(而不是segue),因为我同时推送根视图和细节视图控制器,只显示详细视图代码)

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];

这样做完美,EXCEPT表示拆分之前或之后从未调用splitView委托方法。如果我在纵向模式下执行此操作,则在推送detailViewController后,下拉主窗口按钮的按钮不显示UNTIL,我旋转到横向模式,然后回到纵向模式。

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.

如何导致willHideViewController / willShowViewController分割视图控制器委托方法被调用或手动导致它们被调用?

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

推荐答案

所以从我发现,它不会调用方法,因为方向没有改变。

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

你要做的是传递按钮从这个视图控制器已经被绑定到popover,如下所示:

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

这篇关于UISplitViewController不推送新的detailView时调用委托方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆