UPDATE - May 2016
UIAlertView is deprecated. You can now use UIAlertController as explained here.
Old Answer with UIAlertView
You can create a UIAlertView like this
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Really reset?"
message:@"Do you really want to reset this game?"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"reset", nil];
[alert show];
To handle AlertView button click, you have to
conform to UIAlertViewDelegate
protocol.
@interface YourViewController:UIViewController<UIAlertViewDelegate>{
.......
.......
}
Then implement UIAlertViewDelegate
protocol methods,
- (void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == [alertView cancelButtonIndex]){
//cancel clicked ...do your action
}else{
//reset clicked
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…