ios - 在容器中显示 UIViewController

标签 ios swift

我有一个 UIViewController。在这个 UIViewcontroller 中有一个容器。在这个容器中是一个标签栏 Controller 。其中一个选项卡是嵌入在导航 Controller 中的 PageViewController。其中一个页面是 UITableViewController。

UIViewController->Container->TabBarController->NavigationController->PageViewController->UITableViewController

如果您单击其中一个单元格,我想显示一个 UIViewContoller。但是这个 UIViewcontroller 应该只在容器和 NavigationController 中。如果我单击一个单元格,您可以在 0.3 秒内看到正确的结果。在导航栏上有一个“后退”按钮。但随后 UIViewController 切换到全尺寸。

我按如下方式显示 UIViewController:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let vc = storyboard.instantiateViewControllerWithIdentifier("article")
        self.presentViewController(vc, animated: true, completion: nil)

我得到以下警告:

Presenting view controllers on detached view controllers is discouraged <Test.AllArticlesTableViewController: 0x7f812bd227d0>.

我希望有人能帮助我。

最佳答案

呈现 View Controller 将默认占据全屏。我相信您正在寻找的是将 View Controller 推送到导航堆栈上。使用 pushViewController(_:animated:)

示例:

self.navigationController.pushViewController(vc, animated: true)

"Pushing a view controller causes its view to be embedded in the navigation interface."

请引用Apple docs获取更多信息。

关于ios - 在容器中显示 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39068930/

相关文章:

ios - 如何将 UIViewController 作为参数传递给 swift 3?

Swift,字典解析错误

ios - 计算 scrollView 中的精确缩放

ios - 调用另一个类的函数(协议(protocol))

ios - 有没有办法从 CGAffineTransform 制作 NSAffineTransform?

ios - 设置位于 UICell 中的 UIButton 的标题

xcode - 隐藏 UICollectionViewCell 中的 View

ios - Firebase 存储下载到本地文件错误

ios - 如何设置 NSBatchDeleteRequest 的 NSBatchDeleteResult 类型?

ios - 将 UINavigationController 呈现为模态,状态栏问题