如何使用一个ViewController切换/更新ViewController?

问题描述 投票:0回答:1

enter image description here

enter image description here

假设我有6个不同的viewControllers,其中包含不同的内容,以及一个mainViewController。而且MainViewcontroller包含一个collectionView iside,并且当它的一个单元格被选中时,我想拥有另一个独立的ViewController,它将更新和切换功能处理到相应的(在这种情况下为6个不同的Controller)viewControllers。到目前为止,已经实现了storyBoard showSegue方法,但是它是可行的,但是我认为这不是最干净,最正确的方法,因为storyBoard seagues对该方法有些混乱,任何人都可以通过此方法向我解释或指导我如何进行操作..?

ios swift xcode storyboard collectionview
1个回答
1
投票

我认为您应该避免将多个视图控制器放在一个情节提要中。我更喜欢使用Coordinator模式。这是一个示例:https://www.hackingwithswift.com/articles/71/how-to-use-the-coordinator-pattern-in-ios-apps

在我的项目中,每个ViewController使用一个Storyboard,并且有一个协调器,可以从应用程序中的任何位置进行访问。它使您的代码超级灵活。试试看...

© www.soinside.com 2019 - 2024. All rights reserved.