开发者

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 touc开发者_高级运维h 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?


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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜