0

I created a working app using Master-Detail storyboard, then decided to move the search to a new page before the table view page.

Storyboard
(source: photoandgem.com)

Part of the problem is one of structure:

  1. Should I have a new navigation controller that embeds the search view controller?

  2. Or should the search view controller be embedded in the original (table view) navigation controller?

  3. Or some other structure?

As is, I set the search view controller as the initial view controller, but the code is incorrect in AppDelegate.swift so I get an error

"Could not cast value of type 'searcher.searchViewController' (0x10bd12dc8) to 'UISplitViewController'."

I know it should have the search view controller incorporated, but I don't know how to fix that.

 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
}

I read all the Apple documentation, and several tutorials, and countless questions/answers on stackoverflow, and I have no problem with the Master-Detail structure without the new search view controller, but I don't understand enough to proceed.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Dan Ferry
  • 3
  • 1
  • 3

1 Answers1

0

There is no recommended structure for adding a swift view controller before a table view navigation controller. As explained in iOS: UISplitViewController cannot be pushed to UINavigationController, it can't be done.

I'm working on a different solution with a search page as a subview of the Master view.

Community
  • 1
  • 1
Dan Ferry
  • 3
  • 1
  • 3