UISplitViewController纵向模式缺少UIBarButtonItem [英] UISplitViewController portrait mode missing UIBarButtonItem

查看:52
本文介绍了UISplitViewController纵向模式缺少UIBarButtonItem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有UISplitViewController的应用程序,当我在potrait模式下启动该应用程序时,它缺少组" UIBarButtonItem.我需要转到横向模式并回到potrait才能显示它.当我以横向模式启动它时,它就在那里.以下是一些清晰的屏幕截图:

I have an application with a UISplitViewController, when I launch the app under potrait mode it's missing the "Group" UIBarButtonItem. I need to turn to landscape mode and back to potrait to make it appear. When I launch it in landscape mode it is there. Here's some screenshot to make it clear:

这是当应用程序以纵向模式启动时

This is when the application is launched at portrait mode

从纵向模式旋转后,它处于横向模式:

This is in landscape mode, after rotating it from portrait mode:

这是从横向模式转回到纵向模式后的情况:

This is after rotating back to portrait mode from landscape mode:

推荐答案

几天前,我也发生了同样的事情.您只需要确保详细信息视图是splitView的委托即可.如果您尝试在详细信息视图的viewDidLoad中设置委托,则只有在splitView加载后(使用root tableView控制器),才可以设置委托.这就是为什么直到您切换到风景然后再回到它之前都不会放置它的原因.设置委托的最佳方法是在您的应用程序委托实现文件中(当创建UISplitViewController时,这是最好的主意)或在根tableView控制器中使用类似

The same thing happened to me a couple days ago. You just have to make sure that the detail view is delegate of the splitView. If you try to set the delegate in the detail view's viewDidLoad, it won't be set until after the splitView loads (with the root tableView controller). That is why it is doesn't get placed until you switch to landscape and back. The best way to set the delegate is either in your app delegate implementation file (when you create the UISplitViewController, which would be the best idea) or in the root tableView controller with something like

- (void)viewDidLoad {
    self.splitViewController.delegate = [self.splitViewController.viewControllers objectAtIndex:1];
}

这使详细信息视图成为委托,因此在tableView控制器加载后加载它时,它将调用您的splitViewController:willHideViewController:...方法.

That makes the detail view delegate, so when it loads after the tableView controller loads, it will call your splitViewController:willHideViewController:... method.

当然,这可能不是您遇到的情况.我只是假设由于我的行为完全相同,所以可能是相同的原因.如果这样做不能解决问题,请这么说,我们将着手解决问题

Of course, this may not be the situation you have. I'm just assuming that since I had the exact same behavior, it is probably the same cause. If this doesn't do the trick, just say so and we'll get to the cause

这篇关于UISplitViewController纵向模式缺少UIBarButtonItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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