【发布时间】:2015-02-28 09:09:36
【问题描述】:
当以模态方式呈现视图控制器时,设置过渡样式似乎会造成内存泄漏。当下面的第三行没有被注释掉时,新的视图控制器没有响应,XCode 的 Debug Navigator 中的内存指示器稳步攀升,最终应用程序崩溃。当该行被注释掉时,它工作得很好。
- (IBAction)settingsPressed:(id)sender {
SettingsPopupViewController *pvc=[[SettingsPopupViewController alloc] init];
pvc.partyPlanName=[self partyPlanName];
//pvc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
pvc.modalPresentationStyle = UIModalPresentationFormSheet;
pvc.delegate=self;
[self presentViewController:pvc animated:YES completion:nil];
}
过渡样式之类的东西会导致这种情况似乎很奇怪,所以我的猜测是 UIModalTransitionStyleFlipHorizontal 的较长过渡时间可能会导致 SettingsPopupViewController 出现问题。也就是说,注释掉该对象中的所有 viewDidLoad 和 viewWillAppear 代码并没有任何区别。这种过渡风格是否存在任何已知问题?感谢阅读。
更新: 查看 Instruments 中的问题表明,当取消注释过渡行时,类别为“Malloc 272 字节”的行会稳步增加。
【问题讨论】:
-
^(void){}????就说nil...好吧,更严肃点——使用仪器!它会准确地告诉您所有内存的去向以及原因。不用问,不用猜。
标签: ios memory-leaks