【发布时间】:2011-11-03 16:14:01
【问题描述】:
我正在尝试将自定义 UIViewController 类弹出到导航控制器,然后当不再查看弹出的控制器时,将其释放。但是,视图控制器仍然存在,我不知道为什么。任何帮助将不胜感激。
界面:
@property (nonatomic, retain) CustomViewController *viewcontroller;
实施:
CustomViewController *vc = [[CustomViewController alloc] initWithNibName:@"CustomViewController" bundle:nil];
self.CustomViewController = vc;
[vc release]; // Release this after setting property to avoid memory leak.
[[self navigationController] pushViewController:[self.CustomViewController autorelease] animated:YES];
// Push in the next view. My thinking is that since pushViewController retains this view, if I autorelease when I send the view, the only thing still retaining the view when it shows up will be the navigation controller, and thus when it is bounced back off of the navigation stack, it should be deallocated. But apparently that's not happening..
【问题讨论】:
标签: iphone objective-c release viewcontroller dealloc