当我在没有动画的情况下推送 UIViewController 时无法设置插座
我有一个 UINavigationController,我可以使用 pushViewController:animated:
将 UIViewController 推送到它上面。之后,我在该传入视图上调用一个方法来设置它的一些 IB 出口。不幸的是,这些只有在我为视图设置动画时才会设置。
所以这会起作用:
MyViewController *newView = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
[self.navigationController pushViewController:newView animated:YES];
[newView updateOutletsForObject:myObject];
但这不会:
MyViewController *newView = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
[self.navigationController pushViewController:newView animated:NO];
[newView updateOutletsForObject:myObject];
有谁知道为什么会发生这种情况?提前致谢。
I have a UINavigationController with which I push UIViewControllers onto using pushViewController:animated:
. After this, I call a method on that incoming view to set some of its IB outlets. Unfortunately, these only get set when I animate the view.
So this will work:
MyViewController *newView = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
[self.navigationController pushViewController:newView animated:YES];
[newView updateOutletsForObject:myObject];
But this won't:
MyViewController *newView = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
[self.navigationController pushViewController:newView animated:NO];
[newView updateOutletsForObject:myObject];
Does anyone know why this would be happening? Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,父视图控制器不应该设置子视图控制器。您应该在子视图控制器的
-viewDidLoad
中处理 IBOutlet 连接。It seems to me that the parent view controller shouldn't be setting up the child's outlets. You should be handling IBOutlet connections in
-viewDidLoad
of the child view controller.