groomsy
groomsy

Reputation: 4955

UISearchBar with UIPopoverController holding results cannot be interacted with while UIPopoverController is on screen

I have a UISearchBar. When the user touches the UISearchBar, a UIPopoverController is shown that contains a UITableView of results. As the user types, the results appear.

I want the user to be able to touch the grey x button in the UISearchBar to clear the search results and clear the UISearchBar's text field. However, the first touch simply dismisses the UIPopoverController, prompting the user to touch the button a second time to clear out the text field.

Is there a way to allow touch interaction with other object while a UIPopoverController is showing?

Upvotes: 6

Views: 3367

Answers (1)

user467105
user467105

Reputation:

Try setting the passthroughViews property of the UIPopoverController to the UISearchBar.

In fact, the Apple sample app ToolbarSearch does exactly this:

// Ensure the popover is not dismissed if the user taps in the search bar.
popover.passthroughViews = [NSArray arrayWithObject:searchBar];

Upvotes: 7

Related Questions