UISplitViewController - Show popover for master vi

2019-07-23 12:22发布

Is it possible to show master view in popover on viewDidLoad (when the view is in portrait orientation)?

2条回答
闹够了就滚
2楼-- · 2019-07-23 12:42

Solution 1:

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

Solution 2:

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

But the trick is when to use these statements. I had to use a flag for this purpose, in order to show the popover only once on startup, and only after i have a reference to my popoverController i.e. after split view delegate method calls.

查看更多
神经病院院长
3楼-- · 2019-07-23 13:04

With iOS 8.0 the Splitviewcontroller supports a preferredDisplayMode which might be an elegant solution for this use case. From Apple Documentation:

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.
查看更多
登录 后发表回答