Navigating to and from a Split View controller
The problem is that the split view controller have to be the root of your app. You cannot push it in a UINavigationController
. Whenever you want the split view to appear/disappear, you should change the rootViewController
(in the AppDelegate
).
However, in your case I suggest you keep the SplitViewController
on the screen all the time, and do the search in the master controller. Use a UITableViewController
in it. You can add a search bar to your table, and narrow the results as you type characters in the search bar. Hope this helps!
Best way to switch between UISplitViewController and other view controllers?
Touche! Ran in to the same issue and solved it the same way using modals. In my case it was a login view and then the main menu as well to be shown before the splitview. I used the same strategy as thought out by you. I (as well as several other knowledgeable iOS folks I spoke to) could not find a better way out. Works fine for me. User never notices the modal anyway. Present them so. And yes I can also tell you that there are quite a few apps doing the same under the hood tricks on the App store. :) On another note, do let me know if you figure a better way out somehow someway sometime :)
How to go back to the initial ViewController the right way?
It doesn't move to another view controller, because you are setting a simple view controller in your rootViewController.
What you need is:
let initialViewController = self.storyboard!.instantiateViewController(withIdentifier: "Initial")
let navController = UINavigationController.init(rootViewController: initialViewController)
UIApplication.shared.keyWindow?.rootViewController?.present(navController, animated: true, completion: nil)
This will create a navigationviewcontroller, so when on "Initial" you should be able to perform push, present actions of another view controllers.
Master detail application initial view controller change
Try to embed your controller with Navigation controller as below :
Select Navigation controller
UISplitView's MasterViewController and Navigation Issue
The problem that you addressing wrong UINavigation controller. I assume before splitting both master and SpeciesViewController existed in same navigation environment, and use same navigation controller. But in split view they don't. Your detail controller is actually UINavigation controller you are looking for, that had to control all navigation, and had to have buttons you need. You can get it from master as:
guard let split = splitViewController, let navController = split.viewControllers.last as? UINavigationController else { return }
And make sure that you split controller not embedded into another UINavigationController (reason for second navigation bar).
EDIT:
Function to return detail's Nav Controller:
var detailsNavigationController: UINavigationController? {
return splitViewController?.viewControllers.last as? UINavigationController
}
To access blue call detailsNavController, to access red use navigationController.
Related Topics
Cannot Convert Value of Type 'Foo!' to Expected Argument Type 'Foo!'
Xcode + Swift + Darwin.Ncurses = "A_Bold Not Found" Compilation Error. I Can't Get Bright Colors
Swift Google Maps Smoothly Rounded Polylines
How to Get Address in English Language Only Using Gmsgeocoder
Firebase Data Structure Best Practice for User Interaction
Cannot Divide and Assign Int64 Value
How to Cache Cells and Also Reuse Cells in a Collectionview That Has Avplayers Embedded in Each Cell
Biometric Authentication Evaluation with Swiftui
Swift Package: Ld: Warning: Dylib Was Built for Newer Macos Version (11.0) Than Being Linked (10.15)
Tableview to Display Different Images on New Controller
Anyobject? Does Not Have a Member Named "Removeatindex"
Swiftui App Crashes Every Time When Trying to Add Item to Grouped Items
How to Constrain 'self' to a Generic Type
Implementing Ignoredproperties() on Both a Object Subclass and Its Own Subclass