views:

226

answers:

2

Hi,

I'm using a UISearchDisplayController with a UISearchBar. I put this UISearchBar in my app using IB and I get :

alt text

Fine : when you start taping, the result popovercontroller appears magically (I didn't write anything on my own to make it appear !)

Then, when a row is clicked among the result, I want to dismiss the PopoverController BUT at this stage, I never instantiated the UIPopoverController on my side : it looks like if there's an encapsulated behavior in the UISearchDisplayController that automatically wraps its searchContentsController inside a UIPopoverController. That's really great because everything works perfectly without doing anything except that I cannot get the reference to this UIPopoverController to dismiss it :(

Does anyone know how to get the reference to this "magically" created UIPopoverController ? (this is the proof the iPad is really a "magical" device ;)

I thought there would be a reference to the UIPopoverController from its contentController (through its parent property for instance), but I cannot find any way to get a pointer to it :/

A: 

Can you add some more details on how you have wired up the UISearchDisplayController in IB? It does not do anything special with UIPopoverControllers on the iPad so I assume you have set the searchContentsController to a controller that is a UIPopoverController? If so then you already have the reference you need, though normally you do not need to dismiss this view, it is dismissed for you when you cancel the search.

kharrison
the UISearchDisplayController is not wired with anything special : http://bit.ly/bESjTT I've uploaded a very basic XCode project that just isolates the use case at http://bit.ly/aG3qAY It's just the Split view controller project example, with a UISearchDisplayController added. In this project, no UIPopoverController is instantiated :/ The SearchContentController is set to a UIViewController and not to a UIPopoverCOntroller.
yonel
+2  A: 

Does [searchDisplayController setActive:NO animated:YES]; not work then?

jrtc27
You know what ? I just thought about trying this but before, I checked if someone answered the question on SO and yes, you're right, it works ! I'm glad to give you the +100 just before the deadline ! :p
yonel
Glad I could help. I hadn't even checked that it worked, but just looked at Apple's Developer Documentation. ;)
jrtc27
Could you please give me the bounty reward (the blue button-thing)? jrtc7
jrtc27
yonel? You HAVEN'T given me the +100 yet!!!!!!! See ^^
jrtc27
You didn't get the +100 ? :( Sh... this was my first bounty, I thought that I just had to validate you post as "answered" and you would get the +100 ?! :'( It looks like you get 50 from "the community". (I also voted up for your answer) Sorry for that, the bounty has just expired, I don't know if I can correct this (on my side, anyway, I lost the 100).
yonel
Don't worry - I got 1/2 from the auto-bounty.
jrtc27