Uiview IBOutlet没有释放
我有这个问题。我有两个IBO门店和as酒店,我将保留它们Uiview IBOutlet没有释放,uiview,release,retain,iboutlet,Uiview,Release,Retain,Iboutlet,我有这个问题。我有两个IBO门店和as酒店,我将保留它们 @interface MCNavigationController : UIViewController @property (retain, nonatomic) IBOutlet UIView *contentView; @property (retain, nonatomic) IBOutlet MCNavBar *navBar; @end 问题是,在dealloc中,在我完成所有发布之后,contentView和navBa
@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
2012-08-2114:48:05.646 ShopRite[4250:12503]
2012-08-21 14:48:05.649 ShopRite[4250:12503]
2012-08-21 14:48:05.650 ShopRite[4250:12503]
2012-08-21 14:48:05.650 ShopRite[4250:12503]
ShopRite[4250:12503]
2012-08-21 14:48:13.726 ShopRite[4250:12503]***-[MCNavigationController视图]:发送到解除分配实例0x66b5f20的消息
但我应该会收到一条“发送到navBar和contentView的解除分配实例的消息,就像我为self.view设置的et一样。我很确定我不会在其他任何地方保留它们,也不会将它们添加到其他视图中。”
如果您有任何建议,我们将不胜感激。我假设您正在使用xib 如果您使用的是xib,那么当它从superview或从窗口中删除时,它将被释放 当我们使用IBOutlet时,我们不需要进行发布 在我完成了所有的发布之后,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);
这些观点可以通过多种方式保留:
UIViewController
的dealloc
中发布,这发生在dealloc
的末尾,因此它不会发生在您记录它的地方UIViewController
的dealloc
中释放,这将发生在dealloc
的末尾我使用的是nib,调用了ViewController dealloc方法,因此它的视图将从superview中删除,但这两个插座未正确释放。如果属性是使用retain创建的,则需要在dealloc中释放它。