我的应用程序通过UIActionSheet向用户询问他们想要从(Photo Library或Camera)导入图像,然后启动相应的UIImagePickerController。
如果用户选择相机,我想首先显示带有与应用相关的相机说明图像的UIAlertView。这样可行,但是当警报仍在屏幕上并显示在屏幕后面时,UIImagePickerController会启动。如果用户取消UIAlert,我该如何启动相机?
-(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex != [actionSheet cancelButtonIndex]) {
// User hasn't canceled, launch chosen photo source
NSString *selectedButtonTitle = [actionSheet buttonTitleAtIndex:buttonIndex];
if ([selectedButtonTitle isEqualToString:@"Camera"]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"\n\n\n\n\n\n\n\n\n\n" delegate:self cancelButtonTitle:@"Done" otherButtonTitles:nil];
UIImageView *cameraHelpView = [[UIImageView alloc] initWithFrame:CGRectMake(82, 46, 120, 160)];
UIImage *cameraTutorial = [UIImage imageNamed:@"cameraTutorial.png"];
cameraHelpView.image = cameraTutorial;
[alert addSubview:cameraHelpView];
[alert show];
[alert release];
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController: picker animated: YES];
[picker release];
}
答案 0 :(得分:1)
为UIAlertView实现委托并实现alertView:didDismissWithButtonIndex:以启动UIImagePickerController。