热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何以编程方式显示UISplitViewControllerMaster?-HowtoshowUISplitViewControllerMasterprogrammatically?

ItrytoshowthemasteroftheSVCprogrammatically.我尝试以编程的方式显示SVC的master。Theappisuniversal.

I try to show the master of the SVC programmatically.

我尝试以编程的方式显示SVC的master。

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!)

这个应用程序是通用的。我有一个TVC关于master,另一个TVC关于细节。用户可以删除细节- tvc上的单元格。在用户删除iPhone (compact)上的详细- tvc中的最后一个单元格后,应该显示主单元格。在iPad(常规)上,选择并显示master-TVC上的下一个现有单元格(工作正常!)

I tried to perform the displayModeButtonItem's action manually but nothing happens:

我尝试手动执行displayModeButtonItem的操作,但是什么都没有发生:

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.

为了测试在细节- tvc的导航栏上添加的“Show”按钮,并执行上述功能。

@IBAction func do_ShowMaster(sender: BaseUIBarButtonItem) {

    self.navigationController!.splitViewController?.toggleMasterView()

}

Storyboard: Storyboard Thank you in advance.

故事板:提前谢谢。

1 个解决方案

#1


1  

@IBAction func do_ShowMaster(sender: BaseUIBarButtonItem) {

    self.splitViewController?.preferredDisplayMode = UISplitViewControllerDisplayMode.allVisible 

}

推荐阅读
author-avatar
jiho_b
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有