UIActionSheet的用法

来源:互联网 发布:motec软件 编辑:程序博客网 时间:2024/06/14 17:34

首先展示一下什么事UIActionSheet,如图:
ActionSheet

1>首先使用UIActionSheet的控制器得要遵守协议,并实现协议方法:

 - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{    if (buttonIndex != 0) return; //0指按了确定。如果按键多了可以用case语句。    [self.navigationController popViewControllerAnimated:YES];//如果选择了确定,既将此控制器从根视图控制器中推出。}

2>UIActionSheet是由于某些操作才会触发的,不如按键之类的,所以相应的代码大概类似下面:

- (IBAction)back:(id)sender {    UIActionSheet *ic =[[UIActionSheet alloc ]initWithTitle:@"重要提示" delegate:self  cancelButtonTitle:@"取消" destructiveButtonTitle:@"确定" otherButtonTitles:nil, nil];    [ic showInView:self.view];//不要忘记将ic显示到当前控制器的View里面。}
0 0
原创粉丝点击