UI UIActionSheet

来源:互联网 发布:文化部网络直播黑名单 编辑:程序博客网 时间:2024/05/16 17:47
<span style="font-size:18px;">    UIActionSheet *actionSheet=[[UIActionSheet alloc]initWithTitle:@"标题" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"destructiveButtonTitle" otherButtonTitles:@"otherButton", nil];    //添加Button    //[actionSheet addButtonWithTitle:@"确定"];    //获取对应下标button的标题    NSLog(@"0:%@ 1:%@ 2:%@",[actionSheet buttonTitleAtIndex:0],[actionSheet buttonTitleAtIndex:1],[actionSheet buttonTitleAtIndex:2]);        [self.window addSubview:actionSheet];    [actionSheet release];    self.actionSheet=actionSheet;        UIButton *button=[UIButton buttonWithType:UIButtonTypeSystem];    button.frame=CGRectMake(50, 50, 100, 50);    [button setTitle:@"按钮" forState:UIControlStateNormal];    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];    [self.window addSubview:button];         - (void)buttonAction:(UIButton*)button{    [self.actionSheet showInView:self.window];}- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{    if (buttonIndex==1) {        NSLog(@"otherButton");    }    if (buttonIndex==2) {        NSLog(@"取消");    }    if (buttonIndex==0) {        NSLog(@"destructiveButtonTitle");    }}</span>

0 0
原创粉丝点击