IOS弹出框
参考:http://www.cnblogs.com/minglz/archive/2012/11/27/2788343.html
(1)@interface YYWViewController : UIViewController <UIActionSheetDelegate>
(2)- (IBAction)btnAlert:(id)sender {
UIActionSheet * actionSheet = [[UIActionSheetalloc]
initWithTitle:@"Are you sure?"
delegate:self
cancelButtonTitle:@"No Way!"
destructiveButtonTitle:@"Yes, I'm Sure!"
otherButtonTitles:nil];
[actionSheet showInView:self.view];
}
(3)
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if(buttonIndex != [actionSheet cancelButtonIndex])
{
NSString *msg = nil;
if(_nameTextField.text.length > 0)
msg = [[NSStringalloc] initWithFormat:@"You can breathe easy, %@, everything went OK.", _nameTextField.text];
else
msg = @"You can breathe easy, everything went OK.";
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Something was done"
message:msg
delegate:self
cancelButtonTitle:@"Phew!"
otherButtonTitles:nil];
[alert show];
}
}