UIActionSheet and UIAlertView

来源:互联网 发布:4g网络1g流量能用多久 编辑:程序博客网 时间:2024/06/06 07:24
- (IBAction)buttonPressed:(id)sender {    UIActionSheet *actionSheet = [[UIActionSheet alloc]                                  initWithTitle:@"Are you sure?"                                  delegate:self                                  cancelButtonTitle:@"No Way!"                                  destructiveButtonTitle:@"Yes, I’m Sure!"                                  otherButtonTitles:nil];    [actionSheet showInView:self.view];}Next, add a new method just after the existing buttonPressed: method:- (void)actionSheet:(UIActionSheet *)actionSheet    didDismissWithButtonIndex:(NSInteger)buttonIndex{    if (buttonIndex != [actionSheet cancelButtonIndex]) {        NSString *msg = nil;        if ([self.nameField.text length] > 0) {            msg = [NSString stringWithFormat:                   @"You can breathe easy, %@, everything went OK.",                   self.nameField.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];}}


//  需要签订<UIActionSheetDelegate>协议

0 0
原创粉丝点击