views:

556

answers:

1

This is really causing me fits. I see a lot of info on putting a UISearchBar in the top row of a UITableView -- but I am putting the UISearchBar into the Toolbar at the top of my screen (on the iPad). I cannot find ANYTHING regarding how to handle UISearchBar and UISearchDisplayController using a UIPopoverController on the iPad. Any more info about the UISearchDisplayController using a UIPopoverController would be greatly appreciated. Please help with this as I am at my wit's end.

Using IB, I put a toolbar on the IUView on the iPad. I added the following: Search Bar (not Search Bar and Search Display) to the toolbar. I set the options to be as follows: Show Cancel Button, Show Scope Bar, Scope Button Titles are: "Title1" and "Title2" (with Title2's radio button selected). Opaque, Clear Context and Auto Resize are checked. I hooked up the delegate of Search Bar to the "File's Owner" and linked it to IBOutlet theSearchBar.

In my viewWillAppear I have the following:

    //Just in case:
    [theSearchBar setScopeButtonTitles:[NSArray arrayWithObjects:@"Near Me",@"Everywhere",nil]];
    //Just in case (again):
    [theSearchBar setShowsScopeBar:YES];
    //doesn't seem to do anything:
    //[theSearchBar sizeToFit]; 

    searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:theSearchBar contentsController:self];
    [self setSearchDisplayController:searchDisplayController];
    [searchDisplayController setDelegate:self];
    [searchDisplayController setSearchResultsDataSource:self];
    //again--does not seem to do anything..but people have suggested it:
    [theSearchBar sizeToFit]; 

Okay, so far, I thought, so good. So, I made the File's Owner .m file to be a delegate for: UISearchBarDelegate, UISearchDisplayDelegate.

My issue: I have yet to implement the delegates necessary to do the search but still... shouldn't I be seeing the scopeBar next to the search field when I click into the search field? Just so you know I DO see the log of the characters I type, so the delegate is working.

Here is a routine I used to check to see if IB really put the Scope Bar (UISegementedControl) in the searchbar:

for (UIView *v in theSearchBar.subviews) 
{
    if ([v isMemberOfClass:[UISegmentedControl class]]) 
    {             
        // You've got the segmented control!                 
        UISegmentedControl *scope = (UISegmentedControl *)v;
        // Do your thing here...
        NSLog(@"Found Scope: '%@'\n",scope);
        NSLog(@"Scope Segments: '%d'\n",[v numberOfSegments]);
    }
} 

This shows:

[30013:207] Found Scope: '<UISegmentedControl: 0x68a06b0; frame = (0 0; 200 44); opaque = NO; layer = <CALayer: 0x68a0600>>'
[30013:207] Scope Segments: '2'

So, I know the 2 segments are there. I also know they are not showing up... What am i doing wrong?

Why doesn't the Scope Bar appear? A results UIPopoverController appears with the title "Results" and "No results found" (of course) when i type the first character in my search...but no scope bar. (not that i expect anything other than "No Results Found".

I am wondering where the scope bar is supposed to appear...in the titleView of the UIPopover? In the toolbar to the right of the search area? Where?

A: 

I'm having the exact same problem. Ever figure this out?

Preston Lee
No. Never had answer. Ended up using diff display method. Hoping new sdk fixes this.
Jann