Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different behavior for segue using UISearchController

I must be doing something wrong here. I have a UITableView, and have implemented a UISearchController. I have a Prototype cell linked to the details screen and pass the selected value in the prepareForSegue method.

For the normal view controller, all works OK, a row is selected and the details screen pushed (i.e. slide in from right).

However when there is an active search, using the UISearchController, the details screen is presented modally (i.e. slide up from bottom of screen) without the UINavigationBar (so there is no possibility to go "back")

I am not using didSelectRowAtIndexPath since I have used storyboard to push the details screen

Why is the presenting animation different when the same code in "prepareForSegue" is being correctly called in each case:

// MARK: -  Navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if (segue.identifier! == "PresentContactDetail") {
        // pass person details from selected row
        if let selectedRow = self.tableView.indexPathForSelectedRow()?.row {
            let selectedPerson = self.visibleResults[selectedRow]
            (segue.destinationViewController as ContactDetail).personRecord = selectedPerson
        }
    }
}

Any suggestions gratefully received.

like image 240
redPanda Avatar asked Nov 09 '22 22:11

redPanda


1 Answers

in ViewDidLoad of UITableViewController set definesPresentationContext = true

like image 66
mladen107 Avatar answered Nov 14 '22 23:11

mladen107