当用户在使用UINavigation的视图中按下时,我正在尝试删除Documents目录中的文件。当我运行我的代码时返回然后返回视图,我收到以下错误,应用程序崩溃:
2014-07-28 18:19:42.446 App [13291:a0b]可以生成嵌套的pop动画 在损坏的导航栏中
2014-07-28 18:19:42.798 App [13291:a0b]完成导航 转变为意外状态。导航栏子视图树可能 腐败了。
我的代码
-(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];
}
答案 0 :(得分:1)
如果按下后退按钮,导航控制器已经在弹出当前视图控制器的过程中。试试吧,不要调用popViewControllerAnimated:
如果您需要执行与推/弹视图控制器相关的某些操作,您还可以查看UINavigationControllerDelegate方法。