我有两个ViewControllers,称它们为A(初始VC)和B.它们通过segue连接。我想只在视图B出现时执行操作,所以我添加了viewDidAppear
侦听器。但是,即使只加载A,也会调用B viewDidAppear()
。这是正常的吗?如果是,我该怎么办?
编辑:
第一个VC:
- (IBAction)addBtnPressed:(id)sender {
NSLog(@"add Btn pressed");
}
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
ViewController *destVC = [segue destinationViewController];
destVC.destStation = self.destField.text;
}
这些是连接到按钮
的插座
故事板
日志:
2015-02-06 23:03:35.499 a[47067:2112434] second view did load
2015-02-06 23:03:35.501 a[47067:2112434] first view did load
2015-02-06 23:03:35.586 a[47067:2112434] second view did appear
2015-02-06 23:03:35.588 a[47067:2112434] first view did appear
我不明白为什么第二个视图确实出现之前会被调用,而不是第一个