1

据我所知,我不相信我做错了什么,但是我得到了:

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]; 

}

我用谷歌搜索了它,但是大多数地方都在谈论放置动画:不,但是我没有在下一个屏幕上看到地图。

4

4 回答 4

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 ...

于 2012-07-06T06:23:16.620 回答
2

我发现另一个解决方案可以将我的所有代码转换为情节提要,并且walla,它又可以工作了。甜的。它不像看起来那么难,干杯,tronnick

于 2012-11-29T21:46:24.600 回答
1

确保您没有同时推入两个或更多导航堆栈UIViewControllers

于 2012-07-16T09:20:30.737 回答
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调用有点难看,但我可以让它在我目前疲倦的状态下工作的唯一方法。

于 2013-10-14T23:40:15.593 回答