В моем приложении я пытаюсь запрограммировать переход в коде при выполнении определенного условия. Я вызываю segue, используя [self executeSegueWithIdentifier: Sender]. Это вызывается в IBAction, который вызывается нажатием кнопки UIB. Тем не менее я получаю сообщение об ошибке EXC_BAD_EXCESS. Фактическое сообщение об ошибке прикреплено к другой строке кода, но я думаю, что оно все еще относится к переходу на основе того, что произошло, когда переход был закомментирован. Благодаря NSLogging я знаю, что IBAction действительно вызывается кнопкой.
Метод создания кнопки:
- (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];
}
В моей раскадровке есть модальный переход с идентификатором "menu".
На пару других сообщений по теме, которые я нашел, в основном ответили решения, касающиеся управления памятью. Я использую ARC с IOS 5, поэтому я не думаю, что это проблема. Вся помощь очень ценится, и я могу опубликовать любой другой код, который может помочь.