据我所知,我不相信我做错了但是我得到了:
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.
这是我的代码
- (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];
}
我用谷歌搜索了它,但是大多数地方都在讨论放动画:不过然后我在下一个屏幕上看不到地图。
答案 0 :(得分:4)
每次CLLocationManager通知同一控制器的位置更改时,您都在推送新的控制器。这导致嵌套导航。第一次尝试在该控制器中保存对LocationMapViewController的引用,然后检查它以通知它:
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)];
}
另一种方法是在LocationMapViewController中创建CLLocationManager ......
答案 1 :(得分:2)
我找到的另一个解决方案我可以将所有代码转换为故事板,而walla,它再次起作用。甜。它不像它看起来那么难,干杯,tronnick
答案 2 :(得分:1)
确保您没有同时将两个或多个UIViewControllers
推入导航堆栈。
答案 3 :(得分:0)
我不是100%确定这是否解决了您的具体问题,但是当我尝试在视频控制器出现之前弹出它时,我收到了nested pop animation can result in corrupted navigation bar
消息。覆盖viewDidAppear
以在UIViewController子类中设置一个标志,指示视图已出现(记得也要调用[super viewDidAppear]
)。在弹出控制器之前测试该标志。如果视图尚未出现,您可能需要设置另一个标记,指示您需要在viewDidAppear
内立即弹出视图控制器,一旦它出现。像这样:
@interface MyViewController : UIViewController {
bool didAppear, needToPop;
}
...并在@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;
}
}
重复的popViewControllerAnimated
电话有点难看,但这是我能够在目前疲惫状态下工作的唯一方法。