で「OK」ボタンを押すとUIAlertView
元に戻りたい のですUITableViewController
が、クリックしても元に戻りません。
QuizViewController.h
:
@interface QuizViewController : UIViewController <UIAlertViewDelegate> {
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
@end
QuizViewController.m
-(IBAction)buttonWasClicked:(id)sender{
UIButton *resultebutton= (UIButton*)sender;
if (qCount < totalQuestions) {
id prevQuestion = [appDelegate.qs objectAtIndex:qCount-1];
NSString * correctAns = [prevQuestion labelAns];
if ([correctAns isEqualToString:resultebutton.titleLabel.text])
myScore += 5;
NSLog(@"The button title is %@ ", correctAns);
NSLog(@"The button title is %@ ", resultebutton.titleLabel.text);
NSString *finishingStatement = [[NSString alloc] initWithFormat:@"Your score so far is %i!", myScore];
theScore.text = finishingStatement;
id nextQuestion = [appDelegate.qs objectAtIndex:qCount];
quizLbl.text = [nextQuestion labelQn];
headerLbl.text = [nextQuestion labelHeader];
[qBtn setTitle:[nextQuestion labelBtn] forState:UIControlStateNormal];
[qBtnB setTitle:[nextQuestion labelBtnB] forState:UIControlStateNormal];
[qBtnC setTitle:[nextQuestion labelBtnC] forState:UIControlStateNormal];
[qBtnD setTitle:[nextQuestion labelBtnD] forState:UIControlStateNormal];
qCount++;
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Results" message:[[NSString alloc] initWithFormat:@"Your total score will be %i!", myScore]
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
QuizTableViewController *quizTable = [self.storyboard instantiateViewControllerWithIdentifier:@"quizTable"];
[self.navigationController presentModalViewController:quizTable animated:YES];
}