Note that there are some explanatory texts on larger screens.

plurals
  1. POCan not display target scene after click on row of SearchResultTableView in my navigation controller
    primarykey
    data
    text
    <p>I want to filter a list of entries via UISearchBar and show the details after user clicks a result row. Full list view and details view are linked via a navigation controller. The normal use case (without search) works like charm:</p> <pre><code> (ListOfAllEntries) =&gt; (direct click on row) ==&gt; (Details view for row) </code></pre> <p>This is what should also work:</p> <pre><code>(ListOfAllEntries) =&gt; (Search) - OK! ==&gt; (ListOfFilteredEntries) - OK! ===&gt; (click on result row) - OK! ====&gt; (Details view for row) - BOOUUMMM! UI and Nav.Ctrl broken </code></pre> <p>I am using a UISearchBar (with UISearchDisplayController) to filter an underlying UITableView. As Apple recommends the filtered search results are displayed in the default second table view (searchDisplayController.searchResultsTableView) on top of my original table view with all entries.</p> <p>Everything works fine - the entries are filtered, and I get the right result row indexpath. Until the user clicks a search result row and I want to push the details view for the selected row on top of the navigation controller. My target details view displays BUT then my program is broken in the following ways:</p> <ol> <li>the target view displays slided below the navigation bar (see image#2)</li> <li>If I press "BACK" on the navigation bar I get an empty screen (see image#3) and after a further BACK click my app crashes) <code>uncaught exception 'NSInvalidArgumentException', reason: 'Can't add self as subview'</code></li> </ol> <p>I tried displaying the target view (scene) with a segue:</p> <pre><code>if (tableView == self.searchController.searchResultsTableView) { [self performSegueWithIdentifier: @"showFoods" sender: self]; } </code></pre> <p>and I tried to display the target view via direct push:</p> <pre><code>FoodViewController *fvc = [self.storyboard instantiateViewControllerWithIdentifier:@"FoodViewController"]; [self.navigationController pushViewController:fvc animated:YES]; </code></pre> <p>Both approaches result in the same wrong app behavior.</p> <p>See my images:</p> <ul> <li>Why is my details list below the navigation bar?</li> <li>Why is the navigation stack garbled after I push my details scene?</li> </ul> <p>Any hint would be appreciated.</p> <p>UISearchbar in action:</p> <p><img src="https://i.stack.imgur.com/fTsva.png" alt="UISearchbar in action"></p> <p>After click on search result row - my details scene slides below the navigation bar</p> <p><img src="https://i.stack.imgur.com/E65Ps.png" alt="After click on search result row - my details scene slides below the navigation bar"></p> <p>After pressing "BACK" the scene with all entries does not display</p> <p><img src="https://i.stack.imgur.com/Nozu2.png" alt="After pressing &quot;BACK&quot; the scene with all entries does not display"></p> <p>My storyboard. Note: The red arrow marks the problem. (The segue in the storyboard works well. But If I want to grammatically go the way of the red arrow, my UI is messed up!).</p> <p><img src="https://i.stack.imgur.com/a1xIX.png" alt="Red arrow way messes up the UI"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload