ios - Swift:在 ContainerView 中从 ViewController 单击到 ViewController 的 Storyboard解决方案

标签 ios objective-c swift

我正在构建一个带有固定顶部栏和底部一些固定按钮的应用程序。在我的 MainViewController 中间,我想要在一些表之间切换。我想要的方式:

  • 点击底部的按钮
  • 点击表格中的按钮

为了解决这个问题,我在 MainViewController 中放置了一个 ContainerView。通过单击底部的按钮之一来切换 InsideViewControllers 已经对我有用了。我用苹果解决了它Tutorial以编程方式。通过单击按钮,我更改了 ContainerView 的 childViewController。

当单击 InsideViewController 中的按钮时,我正在向我的 ParentViewController(容器)发送一条消息。我通过实现一个协议(protocol)并检查我的parentViewController 是否实现它来做到这一点。

现在我的问题是,这是否是在 ContainerView 内从 ViewController 单击到 ViewController 的最佳解决方案。或者是否有更好的方法来单击我的表上的按钮并获取下一个表?

我的想法也许是可能的:

Storyboard解决方案。我想在我的 Storyboard中连接 ViewController。这样我的第一个 View Controller 上就有一个按钮,并从这个 View Controller 到下一个 View Controller 。如果我像解释的那样这样做,新的 ViewController 不会填充容器。我的应用程序会弹出一个普通的 ViewController。这是这个想法的示例 View :enter image description here

是否可以或者我是否继续向我的 parent 发送消息?

最佳答案

当然可以。您可以开始阅读Implementing a Container View Controller具体来说,“在 Interface Builder 中配置容器”部分。在添加容器 View 的初始阶段,您将自动看到一个新的 UIViewController 出现在那里。我想如果您想要执行转换,您将必须嵌入新 View Controller 的导航 Controller 。

enter image description here

关于ios - Swift:在 ContainerView 中从 ViewController 单击到 ViewController 的 Storyboard解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44563496/

相关文章:

ios - 如何使用 SwiftyDropbox 下载文件?路径错误

swift - 如何在 Swift 中对数组进行排序

ios - 从周数获取日期,部分标题数为周数

iOS - UITableViewCell 中 UIButton 的延迟 "Touch Down"事件

swift - 占屏幕一半的tabView

ios - 使用UITableView动态显示NSManagedObject的各个属性

UITextView 中的 iOS 可点击文本

ios - “PFObject”不是 'Post' 的子类型 - Swift 错误

ios - 呈现模态视图 Controller 时,核心动画层表现得很奇怪。 CATransform3D 问题

ios - AVAudioEngineImpl::IOUnitConfigurationChanged() 崩溃