如果我有一个带有根视图控制器 MyViewController 实例的导航控制器。
在那个 MyViewController 的代码中,我可以使用
AnotherViewController *vc = [[AnotherViewController alloc] init];
[self presentModalViewController:vc animated:YES];
或者
AnotherViewController *vc = [[AnotherViewController alloc] init];
[self.navigationController presentModalViewController:vc animated:YES];
我发现这两个工作相同。两者都正确显示了模态视图。我发现显示的 AnotherViewController 的“parentViewController”属性都设置为导航控制器。
为什么会出现这种情况呢?presentModalViewController 会自动检测到自己是导航控制器的子视图,然后重新发送消息给导航控制器?