结果:
2014-05-12 11:17:24.891 viewController[2206:60b] init
2014-05-12 11:17:24.910 viewController[2206:60b] loadView
2014-05-12 11:17:24.911 viewController[2206:60b] viewDidLoad!
2014-05-12 11:17:24.912 viewController[2206:60b] viewWillAppear
2014-05-12 11:17:24.916 viewController[2206:60b] dealloc
2014-05-12 11:17:24.982 viewController[2206:60b] viewDidAppear
为什么在viewWillAppear方法和viewDidAppear方法之间使用dealloc方法?
- (id)init
{
if (self = [super init]) {
NSLog(@"init");
}
return self;
}
- (void)loadView
{
NSLog(@"loadView");
[super loadView];
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"viewDidLoad!");
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSLog(@"viewWillAppear");
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSLog(@"viewDidAppear");
}
- (void)dealloc
{
NSLog(@"dealloc");
[super dealloc];
}
答案 0 :(得分:1)
来自您的评论:
方法dealloc日志自我地址已更改! - user3349116
您正在查看来自视图控制器的不同实例的日志。当您尝试跟踪此类活动时,请在日志中添加self
。并且确保在您执行操作时不要破坏视图控制器(您的loadView实现可能意味着您无需在屏幕上显示任何内容)。
在任何情况下,视图控制器生命周期都有详细记录,在大多数情况下非常明显。