gpt4 book ai didi

ios - 转到 DetailViewController (SplitViewController)

转载 作者:行者123 更新时间:2023-11-29 01:32:21 24 4
gpt4 key购买 nike

我很难选择显示为 Split View Controller 中的详细 View 的 View Controller 。似乎在 showDetail 后面有一些 View Controller 的默认调用者,但我找不到在哪里。当分割 View Controller 加载时,它会显示 DetailViewController 作为我尝试将其设置为 OverviewViewController 的分割中的详细信息。 showDetail segue 不会在加载时调用,但它仍然是默认值。

当我覆盖主服务器上的 didSelectRowAtIndexPath 时,我看到闪烁,因为它在设置 OverviewViewController 之前短暂设置了 DetailViewController

这是我的代码:

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.navigationItem.leftBarButtonItem = self.editButtonItem()
if let split = self.splitViewController {
let controllers = split.viewControllers
self.detailViewController = (controllers[controllers.count-1] as! UINavigationController).topViewController as? OverviewViewController

}
}

// MARK: - Segues
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
print("did select row")
NSOperationQueue.mainQueue().addOperationWithBlock {
self.performSegueWithIdentifier("showOverview", sender: self)
}

}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showDetail" {
print("segue to showDetail")
let controller = (segue.destinationViewController as! UINavigationController).topViewController as! DetailViewController
controller.injectOrder(gobl_meal_orders[indexPath.row])
controller.detailItem = object
controller.navigationItem.leftBarButtonItem = self.splitViewController?.displayModeButtonItem()
controller.navigationItem.leftItemsSupplementBackButton = true
}
}else if segue.identifier == "showOverview"{
print("show overview called")
}
}

View Controller 的隐藏预选在哪里?

最佳答案

如果我理解正确,您不希望在加载 splitview Controller 时显示详细 View 。

控制它的方法是为您的 UISplitViewController 使用自定义类并实现以下委托(delegate)方法

splitViewController(_:collapseSecondaryViewController:ontoPrimaryViewController:)

这是一个例子。

import UIKit

class MyCircleUISplitViewController: UISplitViewController, UISplitViewControllerDelegate {

override func viewDidLoad() {
super.viewDidLoad()
delegate = self

// Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

func splitViewController(splitViewController: UISplitViewController, collapseSecondaryViewController secondaryViewController: UIViewController, ontoPrimaryViewController primaryViewController: UIViewController) -> Bool {
return true
}
}

这里也不错blog在 UISplitViewControllers 上你可能会感兴趣。

关于ios - 转到 DetailViewController (SplitViewController),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33323067/

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