开发者

EXC BAD ACCESS while using UISearchBar

I think, I need another good advice. Up to now my solution seemed to run well, but now...

OK, the facts:

  1. I have an ordinary UIViewController
  2. On top a UINavigationBar, behind that a UISearchBar, hidden initially
  3. At bottom a UIToolBar
  4. My main view controller supports UISearchBarDelegate

A switch on UIToolBar toggles the visibility of the UISearchBar

    if (show) {
        [searchBar setShowsCancelButton:TRUE animated:TRUE];
        [navigationBar setHidden:TRUE];
        [searchBar becomeFirstResponder];
    }
    else {开发者_运维技巧
        [navigationBar setHidden:FALSE];
        [searchBar setShowsCancelButton:FALSE animated:TRUE];
    }
    searchIsVisible = !searchIsVisible;

There is some animation around, but I have dropped this for example. It works well, I can enter a search string and access it using "searchBarSearchButtonClicked:". I'm also able to react on "searchBarCancelButtonClicked:"

I either didn't notice it before or it happens right now - I'm occasionally catching an EXC BAD ACCESS without further notice. I'm pretty sure, the "[searchBar becomeFirstResponder];" statement is the reason for that, because I can provoke it with tapping into the search line too.

Unfortunately I'm unable to figure out, what the reason is. Do I have to provide another delegate method, as the two I have right now?

Any pointer welcome.


My guess is that searchBar is being deallocated and you don't know it. Probably because your view controller is being deallocated and/or your view hierarchy. Try breaking in your deallocs and seeing whether when they occur makes sense.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜