私のアプリでは、特定の条件が満たされたときにコード内でセグをプログラムしようとしています。私は[self performSegueWithIdentifier:Sender]を使ってセグを呼び出します。これはIBActionで呼び出され、UIButtonを押すことで呼び出されます。ただし、EXC_BAD_EXCESSエラーメッセージが表示されます。実際のエラーメッセージは別のコード行に付けられていますが、segueがコメントアウトされたときの状況に基づいてsegueを参照していると思います。 NSLoggingを通して、私はIBActionが本当にボタンによって呼び出されていることを知っています。コードセグのXcode-EXC_BAD_ACCESS
ボタンを作成する方法:
- (void)gameOver {
[run invalidate];
[xViewTimer invalidate];
[gameTimer invalidate];
gameOverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
gameOverView.backgroundColor = [UIColor blueColor];
CGRect f = CGRectMake(0, 20, 320, 100);
scoreIs = [[UILabel alloc] initWithFrame:f];
scoreIs.textAlignment= UITextAlignmentCenter;
scoreIs.adjustsFontSizeToFitWidth = YES;
scoreIs.backgroundColor = [UIColor clearColor];
scoreIs.font = [UIFont systemFontOfSize:26];
[scoreIs setText:@"You Finished With A Score Of:"];
UILabel *showPoints = [[UILabel alloc] initWithFrame:CGRectMake(0, 80, 320, 100)];
showPoints.textAlignment = UITextAlignmentCenter;
showPoints.adjustsFontSizeToFitWidth = YES;
showPoints.backgroundColor = [UIColor clearColor];
showPoints.font = [UIFont systemFontOfSize:50];
[showPoints setText:[NSString stringWithFormat:@"%d", points]];
UIButton *playAgainButt = [UIButton buttonWithType:UIButtonTypeRoundedRect];
playAgainButt.frame = CGRectMake(self.view.center.x-70, 200, 140, 50);
[playAgainButt setTitle:@"Play Again" forState:UIControlStateNormal];
[playAgainButt addTarget:self action:@selector(newGame) forControlEvents:UIControlEventTouchUpInside];
UIButton *toMain = [UIButton buttonWithType:UIButtonTypeRoundedRect];
toMain.frame = CGRectMake(self.view.center.x-70, 280, 140, 50);
[toMain setTitle:@"Main Menus" forState:UIControlStateNormal];
[toMain addTarget:self action:@selector(mainMenuSegue:) forControlEvents:UIControlEventTouchUpInside];
scoreIs.hidden = NO;
[gameOverView addSubview:toMain];
[gameOverView addSubview:playAgainButt];
[gameOverView addSubview:showPoints];
[gameOverView addSubview:scoreIs];
[self.view addSubview:gameOverView];
NSLog(@"Game Over");
}
その後mainMenuSegueと呼ばれている:「メニュー」
- (IBAction)mainMenuSegue {
[self performSegueWithIdentifier:@"menu" sender:self];
}
識別子と私のストーリーボードでのモーダルセグエがあります
私が見つけた主題のカップルの他の記事は、主にメモリ管理に関する解決策で答えられました。私はIOS 5とARCを使用しているので、これは問題ではないと思います。すべてのヘルプは非常に高く評価されており、他のコードを投稿することもできます。
感謝をすると思うコンテキストを持っていると思ういけないこの
をしたいと思います。しかし私はこれを試み、同じ応答を得ました。おそらく他のアイデア? – user1110415
さらにデバッグするコードを増やす必要があります – cpjolicoeur
私はいくつかのコードを追加しました。ストーリーボードで問題がセグ自体である可能性はありますか?これは、あるビューコントローラと別のビューコントローラとの間のモーダルセグである。別のビューコントローラに何らかのオブジェクトが必要ですか? Receiver()には、識別子 'menu'を持つセグがありません。しかし、私はそこにセグエがあることを知っています。それは、どうにか間違った種類のセグを信じさせてくれるのです。 –
user1110415