当前位置: 动力学知识库 > 问答 > 编程问答 >

objective c - 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?

网友答案:

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];
分享给朋友:
您可能感兴趣的文章:
随机阅读: