gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 07:26:37 28 4
gpt4 key购买 nike

所以我有一个标签栏应用程序,在其中我放置了一个按钮以转到另一个 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com