我有这个问题。我有两个 IBOutlets 和属性,我保留它们。
@interface MCNavigationController : UIViewController
@property (retain, nonatomic) IBOutlet UIView *contentView;
@property (retain, nonatomic) IBOutlet MCNavBar *navBar;
@end
问题是在dealloc中,在我完成所有发布之后,contentView和navBar仍然没有被释放。
- (void)dealloc
{
[contentView release];
NSLog(@"%@",contentView.superview);
[navBar release];
NSLog(@"%@",navBar.superview);
NSLog(@"%@",self.view);
[super dealloc];
NSLog(@"%@",navBar.superview);
NSLog(@"%@",contentView.superview);
NSLog(@"%@",self.view);
}
在日志中,这就是我得到的:
2012-08-21 14:48:05.646 ShopRite[4250:12503] <UIView: 0x66b77d0; frame = (0 0; 320 416); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x66b7800>>
2012-08-21 14:48:05.649 ShopRite[4250:12503] <UIView: 0x66b77d0; frame = (0 0; 320 416); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x66b7800>>
2012-08-21 14:48:05.650 ShopRite[4250:12503] <UIView: 0x66b77d0; frame = (0 0; 320 416); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x66b7800>>
2012-08-21 14:48:05.650 ShopRite[4250:12503] <UIView: 0x66b77d0; frame = (0 0; 320 416); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x66b7800>>
2012-08-21 14:48:05.651 ShopRite[4250:12503] <UIView: 0x66b77d0; frame = (0 0; 320 416); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x66b7800>>
2012-08-21 14:48:13.726 ShopRite[4250:12503] *** -[MCNavigationController view]: message sent to deallocated instance 0x66b5f20
但我应该得到一个“发送到导航栏和内容视图的释放实例的消息,就像我为 self.view 设置的一样。我很确定我不会将它们保留在其他任何地方或将它们添加到其他视图。
任何建议将不胜感激。