UIAlertView
OKとキャンセルの2つのボタンがあるリロードボタンがあります。キャンセルボタンは正常に機能しますが、アクション(ゲームをもう一度プレイする)をOKボタンに入れたい場合、そのアクションがNSLog
.
私のコードはmです。ファイル:
- (IBAction)startAgainAction:(id)sender {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Warning" message:@"Have you short that want start again the game?"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:@"Cancel", nil];
[alert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
// My OK button
if (buttonIndex == alertView.cancelButtonIndex) {
// Action to start the game again... (don't work)
[self viewDidLoad];
} else if (buttonIndex == alertView.firstOtherButtonIndex) {
// NSLog it's accept but not other actions...
NSLog(@"Cancel");
}
}
はい、UIAlertViewDelegate
プロトコルを h に入れました。ファイル
viewDidLoad
では、メソッドを再度呼び出しても機能しないのはなぜですか?