[戻る] ボタンをクリックすると、アプリがクラッシュし、このエラーが表示されます。私は2つのView Controllerを持っています。最初の vc では、[開始] ボタンを使用して 2 番目のビューに切り替えることができますが、[戻る] ボタンをクリックするとアプリがクラッシュし、@autorelease プールの下の行で上記のエラーが発生します。スタートボタンと戻るボタンのコードも投稿します。thx :) #import #import "AppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
最初の vc.H ファイル スタート ボタン (これは 2 番目のビューに切り替えて動作します)
@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];
}