开发者

Problem resigning UISearchBar's firstResponder status

开发者 https://www.devze.com 2023-01-09 20:41 出处:网络
I\'ve got a UISearchBar开发者_如何学Python on my UITableView and a method -finishSearching which looks like this:

I've got a UISearchBar开发者_如何学Python on my UITableView and a method -finishSearching which looks like this:

- (void)finishSearching {
    [overlayViewController.view removeFromSuperview];
    if ([sb isFirstResponder])
        [sb resignFirstResponder];
    myTableView.scrollEnabled = YES;
}

This method gets called everytime I want to stop searching. Be it using the cancel or the search button or just tapping on the UITableView. The problem is that I always get an EXC_BAD_ACCESS when it comes to [sb resignFirstResponder]; and I have no idea why. My goal is to implement a behavior like in Address Book where you can tap the searchBar which makes it stick to the top and put that grey overlay over the UITableView.

Any suggestions on that one?

Best

–f


Are you sure that by removeFromSuperview the sb will not be released a little too early? Try resigning first and then removing the view from the superview.

0

精彩评论

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