使用pushViewController:动画:
我正在尝试将 PushViewController:animated: 与 UIViewController 一起使用。我将它放置在带有 initWithRoot 的 UINavigationController 中,但它仍然无法工作。
这是我的代码?我做错了什么吗?
CloudappSettingsViewController *cloud = [[CloudappSettingsViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:cloud];
[self pushViewController:nav animated:YES];
[cloud release];
当它达到 [self pushViewController:navanimate:YES];
有什么想法吗? 谢谢
I'm trying to use the pushViewController: animated: with a UIViewController. I have it housed in a UINavigationController with initWithRoot and it still doesn't work.
Here is my code? Am I doing something wrong?
CloudappSettingsViewController *cloud = [[CloudappSettingsViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:cloud];
[self pushViewController:nav animated:YES];
[cloud release];
It always crashes when it gets up to the [self pushViewController:nav animated:YES];
Any ideas?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
“self”是 UINavigationController 吗?
看来您正在尝试推动导航控制器,但这是倒退的。您应该呈现导航控制器并向其推送其他视图。
因此,您所在的 UIView 应该已经在导航控制器中,然后您可以将云推入其中。
is "self" a UINavigationController?
It seems you are trying to push the navigation controller, but that is backwards. You should present the navigation controller and push additional views to it.
So the UIView you are in should already be in the nav controller then you would push cloud into that.
如果这是在您的应用程序委托中,只需将 UINavigationController 作为子视图添加到您的应用程序窗口中。如果您想将 UINavigationController 显示为模态视图控制器,请执行以下操作:
If this is in your app delegate, just add the UINavigationController as a subview to your app's window. If you want to present the UINavigationController as a modal view controller then do this:
它肯定会崩溃,因为你将笔尖设置为零。
创建一个笔尖并将其分配给您的视图控制器。
It will crash definitely because you set the nib to nil.
Create a nib and assign it to your view controller.