iphone - 当我尝试转到其他 View 时,模拟器崩溃

标签 iphone view crash tabbar switching

所以我有一个标签栏应用程序,在其中我放置了一个按钮以转到另一个 View 。

所以在FirstView.h中我有

IBOutlet ContactMainViewController *contactMainViewController;

然后
-(IBAction)gotoContactMainViewController;

在我的FirstView.m中
-(IBAction)gotoContactMainViewController {

    [self presentModalViewController:contactMainViewController animated:YES];
}

并在.h中创建的SecondView中
-(IBAction)goBack;

并在.m中
-(IBAction)goBack {

    [self dismissModalViewControllerAnimated:YES];
}

该应用程序正常运行,但是当我单击按钮时,出现绿线
[self presentModalViewController:contactMainViewController animated:YES];

然后说"Thread 1: Program received signal: "SIGABRT"并在控制台中:terminate called throwing an exception[Switching to process 3908 thread 0xb303]
谢谢你的帮助 !

最佳答案

什么样的FirstView和ContactMainViewController类文件?是UIViewController还是简单的UIView?
我们假设ContactMainViewController是一个单独的类文件

在您的firstView.m中

#import "ContactMainViewController.h"

-(IBAction)gotoContactMainViewController {

    ContactMainViewController _contactMainVC = [[ContactMainViewController alloc]init];

    [self presentModalViewController:_contactMainVC animated:YES];
    [_contactMainVC release];
}

Add the @class ContactMainViewController; in the header before the @interface. That should do it. Also be sure to #import "ContactMainViewController.h" in your .m file to avoid warnings

关于iphone - 当我尝试转到其他 View 时,模拟器崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6945766/

相关文章:

iphone - View Controller 和 UIView 之间的简单委托(delegate)不起作用

iphone - 如何在类之间共享串行调度队列?

javascript - Express & jade (node.js) - 检查存在时变量未定义错误

ios - 简单的应用程序崩溃

android - 如何在android中显示类似 "the application has crashed, but a report is sent to the admin"的消息

ruby-on-rails - Ruby on Rails上传到Heroku然后崩溃

iphone - 似乎无法使用 NSArray 调用 NSInitationOperation

iphone - 从 "C Primer Plus"开始学C后选择是否转Objective-C

Android:在 Eclipse 布局查看器中显示自定义 UI View

mysql - MySQL View 是在文件系统上创建和存储的,还是总是在运行时创建的