在我的应用程序中,Leaks 报告说它在以下 3 个区域发生泄漏:
1
NSData *data = [theDictionary objectForKey:@"Item1"];
[image setImage:[UIImage imageWithData:data] forState:UIControlStateNormal];
2
此代码中的第三行
CGRect frame = self.view.frame;
frame.origin.x = CGRectGetMaxX(frame);
view3.view.frame = frame;
[self.view.superview addSubview:view3.view];
[UIView animateWithDuration:2
animations:^{
CGRect frame = self.view.frame;
view3.view.frame = frame;
frame.origin.x -= frame.size.width;
self.view.frame = frame;
}
completion:^(BOOL finished){
[self.view removeFromSuperview];
[self release];
}];
3
此代码中的第一行:
[self.view.superview addSubview:nlView.view];
[nlView.view setFrame:CGRectMake(-kWidth, 0, kWidth, kHeight)];
[UIView animateWithDuration:2.0
animations:^{
[nlView.view setFrame:CGRectMake(0, 0, kWidth, kHeight)];
[self.view setFrame:CGRectMake(kWidth, 0, kWidth, kHeight)];
}
completion:^(BOOL finished){
[self.view removeFromSuperview];
[self release];
}];
我可能已经通过[图像发布]修复了第一个问题;后来,但我认为这不是正确的方法。
对于 2 和 3,从我的角度来看,我什至没有看到任何泄漏,尽管 Leaks 说有。
谁能告诉我在哪里以及如何修复这些泄漏?
谢谢!
最佳答案
我猜你没有清理nlView和view3。
关于ios - 3 我不确定的泄漏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8686250/