简体   繁体   English

UISplitViewController 纵向模式缺少 UIBarButtonItem

[英]UISplitViewController portrait mode missing UIBarButtonItem

I have an application with a UISplitViewController, when I launch the app under potrait mode it's missing the "Group" UIBarButtonItem.我有一个带有 UISplitViewController 的应用程序,当我在 potrait 模式下启动应用程序时,它缺少“组”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:这是在从横向模式旋转回纵向模式之后:在此处输入图像描述

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.您只需要确保详细视图是 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).如果您尝试在详细视图的viewDidLoad中设置委托,则在 splitView 加载(使用根 tableView 控制器)之后才会设置它。 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设置委托的最佳方法是在您的应用委托实现文件中(当您创建 UISplitViewController 时,这将是最好的主意)或在根 tableView controller 中使用类似的东西

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

That makes the detail view delegate, so when it loads after the tableView controller loads, it will call your splitViewController:willHideViewController:... method.这使得细节视图委托,所以当它在 tableView controller 加载之后加载时,它会调用你的splitViewController:willHideViewController:...方法。

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如果这不起作用,就这么说,我们会找到原因

I couldn't figure out this problem either, as my code and IB connections seemed identical to what Apple's Multiple Detail Views sample source code had.我也无法弄清楚这个问题,因为我的代码和 IB 连接似乎与 Apple 的 Multiple Detail Views 示例源代码相同。

I was able to get it to work properly by changing the reference from self.splitViewController (a property of the left view controller's class) in the 2nd to last line to the svc passed in automatically to the method.通过将第二行到最后一行中的self.splitViewController (左视图控制器类的属性)的引用更改为自动传递给该方法的svc ,我能够使其正常工作。 I had noticed in the debugger that the former had not been instantiated yet for some reason.我在调试器中注意到,由于某种原因,前者尚未实例化。 (memory location was 0x00000000). (内存位置为 0x00000000)。

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

// Keep references to the popover controller and the popover button, and tell the detail view controller to show the button.
barButtonItem.title = @"Menu";
self.popoverController = pc;
self.rootPopoverButtonItem = barButtonItem;
UIViewController <SubstitutableDetailViewController> *detailViewController = [self.splitViewController.viewControllers objectAtIndex:1];
[detailViewController showRootPopoverButtonItem:rootPopoverButtonItem];

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 缺少UISplitViewController中的UIBarButtonItem - Missing UIBarButtonItem in the UISplitViewController UISplitViewController - 以纵向模式打开,masterViewController可见 - UISplitViewController - open in portrait mode with masterViewController visible 如何使用UISplitViewController iOS在iPad上以肖像模式强制显示MasterViewController - How to force show MasterViewController in Portrait mode on iPad using UISplitViewController iOS UISplitViewController 始终在 iPad 纵向模式 iOS 9 中显示主视图 - UISplitViewController always show master view in iPad portrait mode iOS 9 在纵向模式下按下新视图控制器后,iOS UISplitViewController的Popover控制器按钮消失 - iOS UISplitViewController's Popover controller button disappear after pushing new view controller in portrait mode UISPlitViewController弹出按钮丢失 - UISPlitViewController popover button missing UISplitViewController,使MasterView以编程方式出现在人像iOS 8中 - UISplitViewController, make MasterView appear programmatically in portrait iOS 8 UISplitViewController中的肖像:如何以编程方式隐藏主弹出窗口? - UISplitViewController in portrait: how to hide master popover programmatically? UISplitViewController - 在 iPad Portrait 中展开和折叠主视图 - UISplitViewController - Expand & Collapse Master View in iPad Portrait 强制人像模式 - Force portrait mode
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM