切换视图给我一个 SIGABRT 消息
我在这里在视图之间切换时遇到了一些困境。
好吧,我的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用:
代替您的代码,它应该可以工作!希望有帮助!
You can use:
Instead of your code and it should work! Hope that helps!
您可以使用 [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];