当我点击返回按钮时,应用程序崩溃并显示此错误。我有 2 个视图控制器。在第一个 vc 上,“开始”按钮可以很好地切换到第二个视图,但是当我点击“后退”按钮时,应用程序崩溃了,并且我在 @autorelease 池下面的行中得到了上面的错误。我还将发布我的开始和后退按钮的代码。thx :) #import #import "AppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
第一个 vc.H 文件开始按钮(这可以切换到第二个视图)
@interface ViewController : UIViewController
{
IBOutlet UIButton *StartQuiz;
IBOutlet UIButton *HowToPlay;
IBOutlet UIButton *Credits;
IBOutlet UIButton *Back;
IBOutlet UILabel *Label;
}
-(IBAction)StartQuiz:(id)sender;
-(IBAction)HowToPlay:(id)sender;
-(IBAction)Credits:(id)sender;
-(IBAction)Back:(id)sender;
Firstvc.M
文件
@implementation ViewController
-(IBAction)StartQuiz:(id)sender {
Questions *MenuToQuestions = [[Questions alloc]
initWithNibName:@"Questions"
bundle:nil];
[self.view addSubview:MenuToQuestions.view];
}
SecondVC.h
文件(后退按钮使应用程序崩溃)
@interface Questions : UIViewController
{
IBOutlet UIButton *BasicOptics;
IBOutlet UIButton *EyeAnatomy;
IBOutlet UIButton *OphthalmicInstruments;
IBOutlet UIButton *Lenses;
IBOutlet UIButton *Transposition;
IBOutlet UIButton *Standards;
IBOutlet UIButton *Frames;
IBOutlet UIButton *Random;
IBOutlet UIButton *Back;
IBOutlet UILabel *Cat1;
IBOutlet UILabel *Cat2;
IBOutlet UIButton *Right1;
IBOutlet UIButton *Right2;
IBOutlet UIButton *Right3;
IBOutlet UIButton *Right4;
IBOutlet UIButton *Wrong1;
IBOutlet UIButton *Wrong2;
IBOutlet UIButton *Wrong3;
IBOutlet UIButton *Wrong4;
IBOutlet UILabel *Answer1;
IBOutlet UILabel *Answer2;
IBOutlet UILabel *Answer3;
IBOutlet UILabel *Answer4;
IBOutlet UILabel *Question;
IBOutlet UILabel *SelectCategory;
IBOutlet UILabel *Lives;
IBOutlet UILabel *Score;
IBOutlet UILabel *LivesWord;
IBOutlet UILabel *ScoreWord;
IBOutlet UILabel *GameOver;
IBOutlet UILabel *FinalScore;
}
-(IBAction)BasicOptics:(id)sender;
-(IBAction)EyeAnatomy:(id)sender;
-(IBAction)OphthalmicInstruments:(id)sender;
-(IBAction)Lenses:(id)sender;
-(IBAction)Transposition:(id)sender;
-(IBAction)Standards:(id)sender;
-(IBAction)Frames:(id)sender;
-(IBAction)Random:(id)sender;
-(IBAction)Right:(id)sender;
-(IBAction)Wrong:(id)sender;
-(IBAction)Back:(id)sender;
@end
Secondvc.m
文件
-(IBAction)Back:(id)sender {
ViewController *MenuToViewController = [[ViewController alloc]
initWithNibName:@"ViewController"
bundle:nil];
[self.view addSubview:MenuToViewController.view];
}