大家好我是新的iphone开发者,
打开uiimagepickercontroller时遇到问题。
我可以选择拍照并在popoverview中打开图库来拍照并打开相机,时间隐藏popoverview并打开图库隐藏弹出框并从父视图控制器打开图像拾取器imagepicker不应该从弹出视图控制器打开。
请分享您的想法。
答案 0 :(得分:2)
//用于打开相机
-(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
答案 1 :(得分:2)
您可以使用UIPopoverControllerDelegate方法
-(void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController;