views:

485

answers:

3

Hi,

I've trying to get a search bar to display in my application.

I'm following the example show in the TableSearch sample application.

I've more or less implemented it exactly the same way apart from the data. I however can never seem to get the actual search bar to display.

The only other difference between my app and the TableSearch app is that mine uses both a tab bar and navigation bar. However I've hacked these into the TableSearch and it still works as expected.

Any suggestions? Anyone else had similar problems to this? This is driving me crazy.

Thanks in advance, Matt

A: 

I had exactly the same problem some time ago. You can read my solution here.

unforgiven
+1  A: 

Just to summarise what I was doing wrong and how I fixed it.

This is what I had previously in my code:

SearchController *searchController = [[SearchController alloc] initWithNibNamed:nil bundle:nil];

(Note: I have a SearchController.xib too)

Which seemed to work fine i.e the nib file loaded and worked except the search bar never displayed.

When I changed the above to:

SearchController *searchController = [[SearchController alloc] initWithNibNamed:@"SearchController" bundle:nil];

It worked as expected.

So the lesson to learn from my mistake is - if you're using a nib file - specify it explicitly.

Hope that helps you, Matt

Sway
A: 

Hi sway,

I am a newbie to iphone application.I am developing an application using TableSearch sample code. I have a rootviewcontroller and when selecting a row it leads to another controller.In that view i have an option for searching the table data. In Tablesearch example they are staring the view as rootviewController. So i am onfused with these lines. Please help me with how u did that. I am trying to get this for more than a week.

  • (void)applicationDidFinishLaunching:(UIApplication *)application { // Create and configure the window, navigation controller, and main view controller.

    // Create the master list for the main view controller. NSArray *listContent = [[NSArray alloc] initWithObjects:

                     [Product productWithType:@"Device" name:@"iPhone"],
    
    
    
                 [Product productWithType:@"Device" name:@"iPod"],
    
    
                 [Product productWithType:@"Device" name:@"iPod touch"],
    
    
                 [Product productWithType:@"Desktop" name:@"iMac"],
    
    
                 [Product productWithType:@"Desktop" name:@"Mac Pro"],
    
    
                 [Product productWithType:@"Portable" name:@"iBook"],
    
    
                 [Product productWithType:@"Portable" name:@"MacBook"],
    
    
                 [Product productWithType:@"Portable" name:@"MacBook Pro"],
    
    
                 [Product productWithType:@"Portable" name:@"PowerBook"], nil];
    

    // Create and configure the main view controller. MainViewController *mainViewController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil];

    mainViewController.listContent = listContent;

    [listContent release];

    // Add create and configure the navigation controller. UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:mainViewController];

    self.navController = navigationController;

    [navigationController release];

    // Configure and display the window. [window addSubview:navController.view];

    [window makeKeyAndVisible]; }

I want to modify these lines in the viewDidload of my viewController. Any help is greatly appreciated.

Thanks Viki