切换视图给我一个 SIGABRT 消息

发布于 2024-12-28 22:17:39 字数 828 浏览 3 评论 0原文

我在这里在视图之间切换时遇到了一些困境。

好吧,我的 iPhone 项目中有一个名为“BaseViewController”的视图控制器类,它是默认的,它有一个名为“GoToNextView”的按钮。我在故事板中添加了另一个名为“NextViewController”的 ViewController,然后创建了另一个名为“NextViewController”的自定义视图控制器类。在故事板上 NextViewController 的检查器窗口下,我将其自定义类更改为“NextViewController;”我想现在一切都应该连接起来了。但是,当我单击“GoToNextView”按钮时,应用程序会停止并显示 SIGABRT 消息。

这是 BaseViewController 类中按钮单击操作的代码。

- (IBAction)Transition_Next:(id)sender 
{
        nextViewController = [[NextViewController alloc] 
                                initWithNibName:@"SecondView" 
                                bundle:[NSBundle mainBundle]];
        [self.view addSubview:nextViewController.view]; 
}

我在这里可能做错了什么?

提前致谢...

I'm having a little predicament switching between views, here.

Alright, so, I have this view controller class in my iPhone project called "BaseViewController," which is the default, which has a button called "GoToNextView." I added another ViewController to the storyboard called "NextViewController," and then I created another custom view controller class called "NextViewController." Under the inspector window for NextViewController on the storyboard I changed its custom class to "NextViewController;" I'm assuming everything should be hooked up, now. When I click on the "GoToNextView" button, though, the application stops with a SIGABRT message.

Here's the code for my button click action in the BaseViewController class.

- (IBAction)Transition_Next:(id)sender 
{
        nextViewController = [[NextViewController alloc] 
                                initWithNibName:@"SecondView" 
                                bundle:[NSBundle mainBundle]];
        [self.view addSubview:nextViewController.view]; 
}

What might I be doing wrong, here?

Thanks in advance...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

飘然心甜 2025-01-04 22:17:39

您可以使用:

- (IBAction)Transition_Next:(id)sender 
nextViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:nextViewController animated:YES];
}

代替您的代码,它应该可以工作!希望有帮助!

You can use:

- (IBAction)Transition_Next:(id)sender 
nextViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:nextViewController animated:YES];
}

Instead of your code and it should work! Hope that helps!

月光色 2025-01-04 22:17:39

您可以使用 [self.navigationController PushViewController:nextViewControllerAnimated:NO];或者如果您没有导航控制器,您可以使用
[自我呈现ModalViewController:nextViewController动画:否];而不是 [self.view addSubview:nextViewController.view];

You can use [self.navigationController pushViewController:nextViewController animated:NO]; or if you don't have a navigation controller, you may use
[self presentModalViewController:nextViewController animated:NO]; instead of [self.view addSubview:nextViewController.view];

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