gpt4 book ai didi

ios - 如何使用 UIContainerView 在 iPad 上隐藏 UISplitViewController master 上嵌入的辅助 UITableViewController 的 DetailView

转载 作者:行者123 更新时间:2023-11-30 13:42:29 25 4
gpt4 key购买 nike

首先对我的英语感到抱歉。我有一个 UISplitViewController ,我用 UIViewController 替换了模板主 UITableViewController ,放置了一个 UITableView 和 UIContainerView ,其中包含第二个静态 UITAbleViewController 用于设置,其中一个设置单元格有另一个详细信息 UITableViewController 来更改其值。在 iPhone 上效果很好,但在带有 splitviewcontroller 的 iPad 上,此设置值表显示在 splitviewcontroller 详细信息 View 上。这也很好,但我不能再隐藏了。 (iPhone 上有后退按钮,效果很好)我找不到解决方案。我的问题是如何隐藏该详细 View 以显示分割 View 的原始详细 View ?这是我的 Storyboard中的 3 张照片、初始 View 以及打开设置值时的照片(无法在 iPad 中隐藏)

任何建议都会很好。谢谢 Storyboard

Ipad screenshots

最佳答案

最后我做了一个简单的解决方案。删除设置 tableviewcontroller 上的显示详细 Storyboard segue 并定义 didSelectRowAtIndexPath 进行自定义推送

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

//i want only the third row to perform an action
if indexPath.row == 2 {
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let groupListViewController = mainStoryboard.instantiateViewControllerWithIdentifier("GroupListViewController") as! GroupListViewController
self.navigationController!.pushViewController(groupListViewController, animated: true)
}

}

这样我就可以将任何 View 推送到 Split View的左侧或右侧,因为两者都有导航 Controller 。之后,我在推送的 tableviewcontroller 上定义了相同的函数,触发一些操作并返回。它在 iPad 和 iPhone 上也同样具有魅力。

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

self.appDelegate.client.selectedGroupIndex = indexPath.row

//The main master viewcontroller of split view
let vehicleListViewController = self.navigationController?.viewControllers.first as! VehicleListViewController

//settingsviewcontroller that embedded in master viewcontroller
let vehicleListSettingsViewController = vehicleListViewController.childViewControllers.first as! VehicleListSettingsViewController

//call a custom function on embedded settings viewcontroller to change selected value
vehicleListSettingsViewController.changeGroup(indexPath.row)

//refresh splitviewcontroller's master tableview
vehicleListViewController.tableView.reloadData()

//Easy go back to masterview
self.navigationController?.popViewControllerAnimated(true)


}

关于ios - 如何使用 UIContainerView 在 iPad 上隐藏 UISplitViewController master 上嵌入的辅助 UITableViewController 的 DetailView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35395332/

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