Reputation: 6490
I am facing this error, when i come back to my old View after visiting a new View (On click of Back Button on navigationBar)
First: On click of searchBar, i am visiting a new View which contains searchBar in place of UINavigationBar
(UINavigationBar
is hidden in new View)..
Here is code snippet, which navigates to new View after clicking searchBar...
- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
{
BTSViewController *Obj = [[BTSViewController alloc] initWithNibName:@"BTSViewController" bundle:nil];
[self.navigationController pushViewController:Obj animated:NO];
}
Second: on click of cancel button in searchBar i am going back to my previous View & in
viewWillDisappear
method i am doing setNavigationBarHidden:NO
Here is code snippet, which comes back to previous View after clicking Cancel button in UISearchBar...
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
[self.navigationController popViewControllerAnimated:NO];
}
I am navigated to my previous view but UINavigationBar
is hidden and shows Unbalanced call error...
in my Log.
Thanks in advance !!
Upvotes: 3
Views: 5828
Reputation: 20541
Here you get this type of error with Two Reasons.
If you pushed more then one UIViewController
at a same time.
In your ViewController.m
's viewDidLoad:
method in not all of the fancy animations have already been finished so your app crahsed
I suggest If you add some Fancy Animations code in viewDidLoad:
method then just replace that type of code from viewDidLoad:
to viewDidAppear:
and Also maintain Queue of your viewControllers..
i hope this answer helpful to you...
Upvotes: 1