使用UIActionSheet警告用户是否确定执行操作

当用户操作具有一定危险性时,可以使用UIActionSheet来警告用户是否继续执行相关操作,比如删除某个文件时,最开始我用UIAlertView弹出窗体来提示用户,以为当[(UIAlertView*) alert show]时程序会等待用户点击按钮处理之后再继续向下执行,但是IOS并不像C#中winform下编程那样,后来就改换了UIActionSheet来执行,如下:

先在.h文件中添加协议

@interface ActionSheetUITableViewController : UITableViewController<UIActionSheetDelegate>

UIActionSheet *actionSheet = [[UIActionSheet alloc]

                                  initWithTitle:@""

                                  delegate:self

                                  cancelButtonTitle:@"取消"

                                  destructiveButtonTitle:@"确定"

                                  otherButtonTitles:nil];

[actionSheet showInView:self.view];


- (void)actionSheet:(UIActionSheet *)actionSheet 

didDismissWithButtonIndex:(NSInteger)buttonIndex {

//等待用户再次确认之后相关的操作代码

}


你可能感兴趣的:(使用UIActionSheet警告用户是否确定执行操作)