UISplitViewController - 在viewDidLoad上显示主视图的弹出窗口

时间:2011-07-28 04:15:51

标签: ios uiviewcontroller orientation uisplitviewcontroller uipopovercontroller

是否可以在viewDidLoad上显示popover中的主视图(当视图处于纵向时)?

2 个答案:

答案 0 :(得分:9)

解决方案1:

[self.popoverButtonItem.target performSelector: self.popoverButtonItem.action withObject: self.popoverButtonItem];

解决方案2:

[self.popoverController presentPopoverFromBarButtonItem:toolbarButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];                

但诀窍是何时使用这些陈述。我必须为此目的使用一个标志,以便在启动时只显示一次弹出窗口,并且只有在我引用popoverController之后,即在分割视图委托方法调用之后。

答案 1 :(得分:0)

对于iOS 8.0,Splitviewcontroller支持preferredDisplayMode,这可能是此用例的优雅解决方案。来自Apple文档:

UISplitViewControllerDisplayModePrimaryOverlay
The primary view controller is layered on top of the secondary view controller, leaving the secondary view controller partially vis{ible.

Available in iOS 8.0 and later.