Reputation: 1028
I try to show the master of the SVC programmatically.
The app is universal. I have a TVC on the master and another TVC on the details. The cells on the detail-TVC can be deleted by the user. After the user deleted the last cell in the detail-TVC on iPhone (compact) the master should be shown. On iPad (regular) the next existing cell on the master-TVC is selected and shown (works fine!)
I tried to perform the displayModeButtonItem
's action manually but nothing happens:
extension UISplitViewController {
func toggleMasterView() {
let barButtonItem = self.displayModeButtonItem()
UIApplication.sharedApplication().sendAction(barButtonItem.action, to: barButtonItem.target, from: nil, forEvent: nil)
}
}
For testing a added a "Show" button on the navigation-bar of the detail-TVC and performed the function above.
@IBAction func do_ShowMaster(sender: BaseUIBarButtonItem) {
self.navigationController!.splitViewController?.toggleMasterView()
}
Storyboard:
Thank you in advance.
Upvotes: 2
Views: 2498
Reputation: 1230
@IBAction func showMaster(sender: BaseUIBarButtonItem) {
self.splitViewController?.preferredDisplayMode = UISplitViewControllerDisplayMode.allVisible
}
Upvotes: 3