Note that there are some explanatory texts on larger screens.

plurals
  1. POUISearchDisplayController not working when created in code?
    primarykey
    data
    text
    <p>I'm working on a tab bar application and one of the tabs has a UISearchDisplayController hooked up to a UISearchBar. It's all connected up in the NIB and is working. When I tap the search bar, the Scope and Cancel buttons fly in etc, and the search delegate updates the results table correctly.</p> <p>However, I'm trying to implement the same code in the <code>viewDidLoad</code> message instead of the NIB, however when I delete the search display controller from the NIB and uncomment my code to create the same controller in the function, it doesn't work. It's as if there's some fundamental connection not being made so that all my search delegate functionality isn't being called.</p> <p>Here's my <em>working</em> NIB version of the Search Display Controller. It's hooked up to the search bar, the <code>UINavigationController</code> subclass (<code>MASearchController</code>) and the root view of that is hooked up as the <code>searchContentsController</code>.</p> <p><a href="http://img192.imageshack.us/img192/3050/screenshot20100307at304.png">alt text http://img192.imageshack.us/img192/3050/screenshot20100307at304.png</a></p> <p>Now this is what you would expect to do in code to create the same, right? What I'm doing is leaving the UISearchBar in the NIB to eliminate one piece of the puzzle at a time in code.</p> <pre><code>// [MASearchController viewDidLoad] UISearchDisplayController *searchController = [[[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:[[self viewControllers] objectAtIndex:0]] autorelease]; [searchController setDelegate:self]; [searchController setSearchResultsDelegate:self]; [searchController setSearchResultsDataSource:self]; </code></pre> <p>I've checked all objects at run time and they all check out. Essentially I've deleted the search display controller from the NIB and then put in the code to create it in the <code>viewDidLoad</code> message.</p> <p>Why would this not work? The search keyboard comes up but none of my search and button animation functionality work???</p>
    singulars
    1. This table or related slice is empty.
    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