I'm using UISPlitViewController in order to show categorized data on the screen. I implemented a search method on master view controller and the flow of data is fine on the iPhone screen, but on the iPad, portrait and landscape, It does work as I want.
I have create a segue (the black arrow points it) to detail controller but it loads data into master view controller.
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showDetail" {
if let indexPath = self.tableView.indexPathForSelectedRow {
let object = categoryID[indexPath.row]
let controller = (segue.destination as! UINavigationController).topViewController as! DetailTableViewController
controller.detailItem = object as Int?
controller.navigationItem.leftBarButtonItem = self.splitViewController?.displayModeButtonItem
controller.navigationItem.leftItemsSupplementBackButton = true
}
//this is the problem!
}else if segue.identifier == "showSearchDetail" {
if let indexPath = self.tableView.indexPathForSelectedRow {
let object = searchResultDrugsID[indexPath.row]
let controller = (segue.destination as! UINavigationController).topViewController as! DrugDetailsTableViewController
controller.detailItem = object as Int?
controller.navigationItem.leftBarButtonItem = self.splitViewController?.displayModeButtonItem
controller.navigationItem.leftItemsSupplementBackButton = true
}
}
}
And here is where the problem lies, I want to load data in detail view controller when user clicks on search results: