大家好,我是新的 iphone 开发人员,
打开 uiimagepickercontroller 时出现问题。
我可以选择拍照并在 popoverview 中打开图库以拍摄照片并打开相机,此时隐藏 popoverview 并打开图库隐藏弹出框并从父视图控制器打开图像选择器图像选择器不应从弹出视图控制器打开。
请分享你的想法。
// 用于打开相机
-(void)btnCameraClicked {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:imgPicker animated:YES];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Camera is not Available" delegate:self cancelButtonTitle:nil otherButtonTitles:@"Ok",nil];
[alert show];
[alert release];
}
}
// 用于打开图像选择器控制器
-(void)btnGalleryClicked {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:imgPicker animated:YES];
}
else {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"Photos are not available" delegate:self cancelButtonTitle:nil otherButtonTitles:@"Ok",nil];
[alert show];
[alert release];
}
}
在此之后,您可以使用 ImagePicking 方法,例如:
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
您可以使用 UIPopoverControllerDelegate 方法
-(void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController;