카테고리 없음2010. 10. 14. 06:50

[아이폰 앱 개발] acton sheet 버튼여러개로 화면 네비게이션

- (IBAction) takePictureButton: (id) sender {

NSLog(@"Taking picture.");

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {

NSLog(@"This device has a camera, ask the what they want to do.");

UIActionSheet *photoSourceSheet = [[UIActionSheet alloc] initWithTitle:@"사진 등록" delegate:self cancelButtonTitle:@"취소" destructiveButtonTitle:nil otherButtonTitles:@"사진 찍기", @"Photo앨범에서 가져오기", nil, nil];

[photoSourceSheet showInView:self.view];

[photoSourceSheet release];

}

else { // No camera, probably a touch

UIImagePickerController *picker = [[UIImagePickerController alloc] init];

picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

picker.delegate = self;

picker.allowsEditing = YES;

[self presentModalViewController:picker animated:YES];

}

}

 

 

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

UIImagePickerController *picker = [[UIImagePickerController alloc] init];

picker.delegate = self;

picker.allowsEditing = YES;

 

 

switch (buttonIndex) {

case 0:

NSLog(@"User wants to take a new picture.");

picker.sourceType = UIImagePickerControllerSourceTypeCamera;

break;

case 1:

NSLog(@"User wants to use an existing photo.");

picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

break;

default:

// They picked cancel

[picker release];

return;

}

[self presentModalViewController:picker animated:YES];

}

Posted by 오늘마감

댓글을 달아 주세요