Reputation: 57
I'm trying to delete a file in my Documents directory when the user presses back in a view with UINavigation. When I run my code go back then go back to the view, I get the following error and the app crashes:
2014-07-28 18:19:42.446 App[13291:a0b] nested pop animation can result in corrupted navigation bar
2014-07-28 18:19:42.798 App[13291:a0b] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
My Code
-(void) viewWillDisappear:(BOOL)animated {
if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
// Navigation button was pressed. Do some stuff
NSString *path = [[NSBundle mainBundle] pathForResource:_url ofType:@"plist"];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *temp = [documentsDirectory stringByAppendingPathComponent:[dict objectForKey:@"FolderName"]];
[[NSFileManager defaultManager] removeItemAtPath: temp error:nil];
[self.navigationController popViewControllerAnimated:NO];
}
[super viewWillDisappear:animated];
}
Upvotes: 0
Views: 31
Reputation: 1629
If the back button has been pressed, the navigation controller is already in the process of popping the current view controller. Try it without the call to popViewControllerAnimated:
If you need to perform certain actions related to pushing/popping view controllers, you can also look into the UINavigationControllerDelegate methods.
Upvotes: 1