UIActionSheet 多项弹出框

/////别忘在.h 写代理 <UIActionSheetDelegate>

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    UIButton* button = [UIButton buttonWithType:UIButtonTypeSystem];
    [button setImage:[UIImage imageNamed:@"main_right_nav.png"] forState:UIControlStateNormal];
    button.frame = CGRectMake(100, 100, 100, 40);
    [button addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
}

- (void)buttonClick{
    UIActionSheet* as = [[UIActionSheet alloc] initWithTitle:@"请选择照片来源" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"照相机" otherButtonTitles:@"相册",@"相册2", nil];
    [as showInView:self.view];
    [as release];
}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    NSLog(@"%d",buttonIndex);
}

UIActionSheet 多项弹出框

你可能感兴趣的:(UIActionSheet,多项弹出框)