您的位置:首页 > 产品设计 > UI/UE

IOS - UIActionSheet 弹出选择按钮项

2017-03-02 22:08 381 查看
加入代理

@interface ImagePickeriewController ()<UIActionSheetDelegate>

@end


添加button的点击响应,响应事件中代码如下

-(void) photoImageClicked{

UIActionSheet *photoSheet;
photoSheet = [[UIActionSheet alloc] initWithTitle:@"选择" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"拍照", @"从相册选择", nil];
photoSheet.tag = 255;
[photoSheet showInView:_photoView];
}


delegate

-(void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{

if(actionSheet.tag == 255){

if (buttonIndex == 0) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"拍照" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:NULL];
[alert show];
}else if (buttonIndex == 1){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"从相册选择" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:NULL];
[alert show];
}else{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"取消" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:NULL];
[alert show];
}
}
}


参考:http://blog.csdn.net/totogo2010/article/details/7618891
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios 弹出按钮 界面