Reputation: 11297
To the best of my knowedge I do not believe I am doing anything wrong however I am getting:
2011-04-02 14:55:23.350 AppName[42430:207] nested push animation can result in corrupted navigation bar
2011-04-02 14:55:23.352 AppName[42430:207] nested push animation can result in corrupted navigation bar
2011-04-02 14:55:23.729 AppName[42430:207] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
2011-04-02 14:55:23.729 AppName[42430:207] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
Here is my code
- (IBAction) btnGetCurrentLocation{
[SVProgressHUD showWithStatus:@"Getting current location..."];
locationManager = [[CLLocationManager alloc] init];
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.delegate = self;
[locationManager startUpdatingLocation];
[SVProgressHUD dismiss];
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
[locationManager stopUpdatingLocation];
CLLocationCoordinate2D coordinate = newLocation.coordinate;
LocationMapViewController *locationMapViewController = [[LocationMapViewController alloc] initWithNibName:@"LocationMapViewController_iPhone" bundle:nil];
locationMapViewController.title=@"Your Title";
locationMapViewController.centerOfMap = &(coordinate);
[self.navigationController pushViewController:locationMapViewController animated:YES];
}
I googled it however most places talk about putting animation:NO however then I do not see the map on next screen.
Upvotes: 1
Views: 6779
Reputation: 149
I'm not 100% sure if this addresses your specific problem, but I got the nested pop animation can result in corrupted navigation bar
message when I was trying to pop a view controller before it had appeared. Override viewDidAppear
to set a flag in your UIViewController subclass indicating that the view has appeared (remember to call [super viewDidAppear]
as well). Test that flag before you pop the controller. If the view hasn't appeared yet, you may want to set another flag indicating that you need to immediately pop the view controller, from within viewDidAppear
, as soon as it has appeared. Like so:
@interface MyViewController : UIViewController {
bool didAppear, needToPop;
}
...and in the @implementation
...
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
didAppear = YES;
if (needToPop)
[self.navigationController popViewControllerAnimated:YES];
}
- (void)myCrucialBackgroundTask {
// this task was presumably initiated when view was created or loaded....
...
if (myTaskFailed) { // o noes!
if (didAppear)
[self.navigationController popViewControllerAnimated:YES];
else
needToPop = YES;
}
}
The duplicated popViewControllerAnimated
call is a bit ugly, but the only way I could get this to work in my currently-tired state.
Upvotes: 0
Reputation: 21
Another solution I found I could convert all my code into storyboard, and walla, it works again. sweet. its not as hard as it looks, cheers, tronnick
Upvotes: 2
Reputation: 4808
Make sure you haven't pushed into navigation stack two or more UIViewControllers
at the same time.
Upvotes: 1
Reputation: 14766
You are pushing a new controller every time that CLLocationManager notify a change of location from the same controller. That results in a nested navigation. Trying to hold a reference to LocationMapViewController in that controller at first time that you are being notified, and later check it to notify it:
if (self.locationController == null){
LocationMapViewController *locationMapViewController = [[LocationMapViewController alloc] initWithNibName:@"LocationMapViewController_iPhone" bundle:nil];
locationMapViewController.title=@"Your Title";
locationMapViewController.centerOfMap = &(coordinate);
[self.navigationController pushViewController:locationMapViewController animated:YES];
}else{
[self.locationController locationDidChangeTo: &(coordinate)];
}
Another alternative is creating the CLLocationManager in the LocationMapViewController...
Upvotes: 4