开发者

Can we change nextResponder?

I got a bunch of sea开发者_如何学Gorch box. Under the search box there are tableviews.

If a user click a tableview (or anything outside the search box), I want search box to lose first responder status.

However, tableview does not have touch up action.

So I add a big button behind the tableview. In the hope that the touch up event get handled by the big button.

Given that the table view completely cover the tableview, this doesn't work.

So what should I do?


I'm not sure whether you use searchDisplayController or just searchBar. but in case you use searchDisplayController, you can implement delegate method

-(void)searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller

which will be called when user click cancel or transparent view (empty search).

An other way to work around your case is set bool to check whether search box is being hold responder or not (set it when search acquire responder). And at cellForRowAtIndexPath, check if that value, and resignFirstResponder and set value false.

Hope this help

Update: Apple's sample code using searchDisplayController

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜