gpt4 book ai didi

ios - 使用 UISplitViewController 的多个 DetailViewController

转载 作者:行者123 更新时间:2023-11-30 13:59:52 28 4
gpt4 key购买 nike

目前,我有一个带有 MasterViewController 和 DetailViewController 的 SplitViewController。我想知道是否有办法拥有更多 DetailViewController。现在,我在左侧的 tableView 中有一个项目列表,如果您单击它们,它们将进入全屏 View 。当单击时,如何才能让它显示在 Split View右侧的面板内?那么引用这张图片 - 我怎样才能让我的 View 像细节部分中的黄色一样显示?现在,当我单击“黄色”时,黄色会全屏显示,而不是细节。 http://2uagoo1zzsoo4bcz3347bs2y.wpengine.netdna-cdn.com/wp-content/uploads/2012/08/Image003.png

额外信息:

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if indexPath.row == 0 {

let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)

let vc: UINavigationController = storyboard.instantiateViewControllerWithIdentifier("newViewController") as! UINavigationController

self.presentViewController (vc, animated: true, completion: nil)

} else if indexPath.row == 3 {

let storyboardTwo: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)

let vcTwo: UINavigationController = storyboardTwo.instantiateViewControllerWithIdentifier("newViewController4") as! UINavigationController

self.presentViewController(vcTwo, animated: true, completion: nil)
}

最佳答案

我相信您需要使用 show showDetailViewController 方法:

将指定的 View Controller 呈现为分割 View 界面的辅助 View Controller 。

func showDetailViewController(_ vc: UIViewController,
sender sender: AnyObject?)

所以在你的情况下它会更像这样使用。在didSelectRowAtIndexPath函数中:

{
let vc:UIViewController
if indexPath.row == 0 {
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
vc: UINavigationController = storyboard.instantiateViewControllerWithIdentifier("newViewController") as! UINavigationController



} else if indexPath.row == 3 {
let storyboardTwo: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
vc: UINavigationController = storyboardTwo.instantiateViewControllerWithIdentifier("newViewController4") as! UINavigationController

}else {
// handle this case
vc = ...
}
// Grab the Split View Controller
let splitVC = // get Split View Controller
splitVC.showDetailViewController(vc,sender:nil)
}

关于ios - 使用 UISplitViewController 的多个 DetailViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33130229/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com