A UIAlertView
is the best way to do that. It will animate into the middle of the screen, dim the background, and force the user to address it, before returning to the normal functions of your app.
You can create a UIAlertView
like this:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Wait" message:@"Are you sure you want to delete this. This action cannot be undone" delegate:self cancelButtonTitle:@"Delete" otherButtonTitles:@"Cancel", nil];
[alert show];
That will display the message.
Then to check whether they tapped delete or cancel, use this:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0){
//delete it
}
}
Make sure in your header file (.h
), you include the UIAlertViewDelegate
by putting <UIAlertViewDelegate>
, next to whatever your class inherits from (ie. UIViewController
or UITableViewController
, etc.)
For more infomation on all the specifics of UIAlertViews
check out Apple's Docs Here
Hope that helps
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…