在 table 视图导航控制器之前添加 swift 视图控制器的推荐结构
Recommended structure to add swift view controller before table view navigation controller
我使用 Master-Detail 故事板创建了一个工作应用程序,然后决定将搜索移动到 table 查看页面之前的新页面。
(来源:photoandgem.com)
部分问题是结构之一:
我应该有一个嵌入搜索视图控制器的新导航控制器吗?
还是应该将搜索视图控制器嵌入到原始(table 视图)导航控制器中?
或者其他结构?
原样,我将搜索视图控制器设置为初始视图控制器,但是 AppDelegate.swift 中的代码不正确,所以出现错误
"Could not cast value of type 'searcher.searchViewController' (0x10bd12dc8) to 'UISplitViewController'."
我知道它应该包含搜索视图控制器,但我不知道如何解决。
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let splitViewController = self.window!.rootViewController as! UISplitViewController
let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController
navigationController.topViewController!.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem
splitViewController.delegate = self
return true
}
我阅读了所有 Apple 文档,还有几个教程,还有无数关于 Whosebug 的 questions/answers,没有新的搜索视图控制器,我对 Master-Detail 结构没问题,但我不明白足以继续。
没有在 table 视图导航控制器之前添加 swift 视图控制器的推荐结构。如iOS: UISplitViewController cannot be pushed to UINavigationController中所述,无法完成。
我正在开发一个不同的解决方案,将搜索页面作为主视图的子视图。
我使用 Master-Detail 故事板创建了一个工作应用程序,然后决定将搜索移动到 table 查看页面之前的新页面。
(来源:photoandgem.com)
部分问题是结构之一:
我应该有一个嵌入搜索视图控制器的新导航控制器吗?
还是应该将搜索视图控制器嵌入到原始(table 视图)导航控制器中?
或者其他结构?
原样,我将搜索视图控制器设置为初始视图控制器,但是 AppDelegate.swift 中的代码不正确,所以出现错误
"Could not cast value of type 'searcher.searchViewController' (0x10bd12dc8) to 'UISplitViewController'."
我知道它应该包含搜索视图控制器,但我不知道如何解决。
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let splitViewController = self.window!.rootViewController as! UISplitViewController
let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController
navigationController.topViewController!.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem
splitViewController.delegate = self
return true
}
我阅读了所有 Apple 文档,还有几个教程,还有无数关于 Whosebug 的 questions/answers,没有新的搜索视图控制器,我对 Master-Detail 结构没问题,但我不明白足以继续。
没有在 table 视图导航控制器之前添加 swift 视图控制器的推荐结构。如iOS: UISplitViewController cannot be pushed to UINavigationController中所述,无法完成。
我正在开发一个不同的解决方案,将搜索页面作为主视图的子视图。