我想检查用户是否单击“是”,例如我想执行某个操作。
这是我的代码行:
UIAlertView* mes=[[UIAlertView alloc] initWithTitle:@"Are you sure?" message:@"this will start a new game" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[mes show];
所以我想说if user tap "yes" preform this action
这是我的方法:我想说如果用户单击“是”创建新游戏。
- (IBAction)newGame:(UIButton *)sender {
UIAlertView* mes=[[UIAlertView alloc] initWithTitle:@"Are you sure?" message:@"this will start a new game" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[mes show];
self.flipsCount = 0;
self.game = nil;
for (UIButton *button in self.cardButtons) {
Card *card = [self.game cardAtIndex:[self.cardButtons indexOfObject:button]];
card.unplayble = NO;
card.faceUp = NO;
button.alpha = 1;
}
self.notificationLabel.text = nil;
[self updateUI];
}