`
jsntghf
  • 浏览: 2478545 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

操作表的使用

    博客分类:
  • iOS
阅读更多

必须使用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 *)actionSheet

didDismissWithButtonIndex:(NSInteger)buttonIndex

{

    if( buttonIndex != [actionSheet cancelButtonIndex]){

        //code here

    }

}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics