1. .m 상단에 tag 정의
#define TAG_ACTION_SHEET 11111
2. .h 에 delegate 추가
@interface SignUpViewController : UIViewController <UIActionSheetDelegate>
3. .m 특정 버튼 클릭시
- (IBAction)clickPhoto:(id)sender
{
UIActionSheet *popup = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:
@"camera",
@"album",
nil];
popup.tag = TAG_ACTION_SHEET;
[popup showInView:[UIApplication sharedApplication].keyWindow];
}
4. .m event 처리부분
- (void)actionSheet:(UIActionSheet *)popup clickedButtonAtIndex:(NSInteger)buttonIndex {
switch (popup.tag) {
case TAG_ACTION_SHEET: {
switch (buttonIndex) {
case 0:
NSLog("camera");
break;
case 1:
NSLog("album");
break;
default:
break;
}
break;
}
default:
break;
}
}