简体   繁体   English

如何从详细视图 controller 以编程方式推送视图 controller

[英]How to push a view controller programmatically from Detail view controller

My app has a split view controller as root with master detail view.我的应用程序有一个拆分视图 controller 作为根,带有主详细视图。 I'm doing this programmatically without using storyboards.我在不使用情节提要的情况下以编程方式执行此操作。 I want to push a new view controller from a button in detail view and close the split view.我想从详细视图中的按钮推送新视图 controller 并关闭拆分视图。 When I tried, it opened inside the detail view.当我尝试时,它在详细视图中打开。 self.navigationController?.pushViewController(mainView, animated: true)

But I want it to open full screen and have a back button to goto the split view.但我希望它打开全屏并有一个后退按钮可以转到拆分视图。 How can I do that?我怎样才能做到这一点?

I think you need either present it Modally or change the rootViewController in corresponding to your action.我认为您需要以模态方式呈现它,或者根据您的操作更改 rootViewController。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM