【发布时间】:2013-07-20 14:10:39
【问题描述】:
我遇到了重大的内存管理问题。使用该程序后,它会因内存不足而崩溃。终于找到原因了,每次新建ViewController而不是访问实例,都是在新建实例。
所以应用程序加载并实例化 FirstViewController。您单击一个实例化FilterViewController 的按钮。从这里返回 FirstViewController 时,我正在创建一个 new 实例,如下所示:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName
:@"MainStoryboard" bundle:nil];
FirstViewController *fvc = [storyboard
instantiateViewControllerWithIdentifier:@"FirstViewController"];
fvc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
然后重复这个过程。有什么方法可以在不重新实例化的情况下呈现视图控制器?我即将提交应用程序(希望明天),所以我需要尝试对此进行排序。谢谢!
这里是 ViewController 的介绍。
[self presentViewController:fvc animated:YES completion:nil];
从FirstViewController呈现FilterViewController
- (IBAction)searchOptions:(id)sender {
FilterViewController *ctrl = [[FilterViewController alloc] init];
[UIView transitionFromView:self.view toView:ctrl.view duration:1 options:UIViewAnimationOptionTransitionCurlUp completion:nil];
self.filterViewController = ctrl;
[self.navigationController pushViewController:self.filterViewController animated:NO];
}
【问题讨论】:
标签: ios objective-c cocoa-touch memory-management