我正在尝试在相当复杂的TabBarController应用程序中调试内存泄漏。因此,我创建了一个非常简单的骨架应用程序,其中包含AppDelegate,FirstViewController和SecondViewController,每个都连接到单独的nib,其中包含iOS编程,Big Nerd Ranch Guide 2nd Ed中指示的视图和标签。选项卡工作,视图显示。当我启用旋转时,我仍然在旋转时在iPad设备上发生泄漏:
CALayer UIKit UIView _createLayerWithFrame UIImageView UIClassicController _setupWindow
编辑:FWIW。我使用了Xcode 3.26和iOS4.3模板:查看 - > iPad - >没有添加代码 - >使用此模板代码在iPad2上测试旋转时没有泄漏:
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
查看 - > iPhone - >在项目之上添加相同的完整代码 - >在iPad2上测试SAME LEAKS 查看 - > iPhone - >添加略有不同的代码 - >在iPad2上测试SAME LEAKS
// Override to allow orientations other than the default portrait orientation.
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)x {
//return YES;
return (x== UIInterfaceOrientationPortrait) || UIInterfaceOrientationIsLandscape(x);
}
所以我要等一下,看看我在测试iPhone4时是否漏了。这是一个非常可重现的错误,需要添加一行代码。困惑。
答案 0 :(得分:-2)
[tbController setViewControllers:viewControllers];
后,您需要使用viewControllers
释放数组[viewControllers release];
。