首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

操作表的运用

2012-07-16 
操作表的使用必须使用Protocol,在类定义的地方定义使用UIActionSheetDelegate协议。?@interface testContro

操作表的使用

必须使用Protocol,在类定义的地方定义使用UIActionSheetDelegate协议。

?

@interface testController : UIViewController <UIActionSheetDelegate> {...}

?

在程序里面调用

?

UIActionSheet *actionSheet = [[UIActionSheet alloc]  initWithTitle:@"Are you sure?"  //标题  delegate:self  //此处指定处理按钮按下之后的事件的类,该类必须实现UIActionSheetDelegate协议  cancelButtonTitle:@"Cancel"  destructiveButtonTitle:@"OK"  otherButtonTitles:@"button1", @"button2", nil];  //可指定多个button,最后一个参数必须为nil[actionSheet showInView:self.view];  //在哪个view里面弹出操作表[actionSheet release];  //一定要release

?

处理按钮事件的方法为实现UIActionSheetDelegate协议的actionSheet方法

?

- (void)actionSheet:(UIActionSheet *)actionSheetdidDismissWithButtonIndex:(NSInteger)buttonIndex{    if( buttonIndex != [actionSheet cancelButtonIndex]){        //code here    }}

?

热点排行