使用pushViewController:动画:

发布于 2024-11-02 10:28:26 字数 557 浏览 6 评论 0原文

我正在尝试将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

土豪 2024-11-09 10:28:26

“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.

笑着哭最痛 2024-11-09 10:28:26

如果这是在您的应用程序委托中,只需将 UINavigationController 作为子视图添加到您的应用程序窗口中。如果您想将 UINavigationController 显示为模态视图控制器,请执行以下操作:

[self presentModalViewController:nav animated:YES];

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:

[self presentModalViewController:nav animated:YES];
笔芯 2024-11-09 10:28:26

它肯定会崩溃,因为你将笔尖设置为零。

CloudappSettingsViewController *cloud = [[CloudappSettingsViewController alloc] initWithNibName:@"NibName goes here" bundle:nil];

创建一个笔尖并将其分配给您的视图控制器。

It will crash definitely because you set the nib to nil.

CloudappSettingsViewController *cloud = [[CloudappSettingsViewController alloc] initWithNibName:@"NibName goes here" bundle:nil];

Create a nib and assign it to your view controller.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文