我想删除堆栈中的所有viewcontrollers(Root除外)以在“内存警告”之后释放内存。
我在最后一个控制器中使用popToRootViewController。
处理: Root(推送) - > AController(推) - > BController(在记忆警告返回后) - >根
(在BController中)
- (void)didReceiveMemoryWarning {
CMLog(@"BController");
[super didReceiveMemoryWarning];
CMLog(@"[allControllers lastObject]");
[self.navigationController popToRootViewControllerAnimated:NO];
}
日志
- 收到内存警告。
- [RootViewController didReceiveMemoryWarning]
- [AController didReceiveMemoryWarning]
- [BController didReceiveMemoryWarning]
- [BController didReceiveMemoryWarning]:[allControllers lastObject]
- (popToRootViewControllerAnimated)
醇>
所以我重复这个过程
- 收到内存警告。
- [RootViewController didReceiveMemoryWarning]
- [AController didReceiveMemoryWarning]
- [BController didReceiveMemoryWarning]
- [AController didReceiveMemoryWarning](<<<< 重复)
- [BController didReceiveMemoryWarning](<<<< 重复)
- [BController didReceiveMemoryWarning]:[allControllers lastObject]
- (popToRootViewControllerAnimated)
醇>
经过多次尝试,应用程序崩溃,因为内存不足
我可以简单地删除stack中的视图控制器吗?并将释放记忆?