0

我正在尝试将UIImagePickerController设置带到UIImagePickerControllerSourceTypeCamera(即当它允许用户拍照时)并自行推送它,UINavigationalController但它不起作用(不能将 a 推UINavigationalController送到另一个上UINavigationalController)。

我想知道,无论如何制作这个相机模块的自定义版本,就像你可以用 UIImagePickerControllerSourceTypePhotoLibrary UIImagePickerControllerusing做的一样ALAssets?我只是不想将相机作为模态视图弹出,而是想自己推送它UINavigationalController

4

3 回答 3

1

您可以使用自定义相机AVFoundation

有关如何使用 AVFoundation 的信息,请参阅Sample AVCam 。

于 2012-12-29T06:24:23.397 回答
1

您的主要问题是它UIImagePickerController本身就是一个 UINavigationController,因此将它推到导航控制器上会有问题(正如您已经发现的那样)

正如 Prince 所提到的,您最好的选择是使用 AVFoundation 创建您自己的。缺点是您将(默认情况下)失去相机应用程序的不错功能,例如触摸对焦、捏合缩放等,但这些都可以自己添加。

查看本教程,它为您提供了有关如何为此使用 AVFoundation 库的很好的解释,还向您展示了如何将叠加等内容添加到相机屏幕。然后你可以很容易地在 google/stackoverflow 上找到如何添加诸如点击聚焦之类的东西:)

于 2012-12-29T07:42:28.647 回答
0

我有同样的问题,但我以这种方式解决了。

如果您
从相机拍摄图片 1)(在两个都打开为 UINavigationcontroller)2)从图库(对于 ipad 作为 UIpopovercontroller 打开和对于 iphone 作为 nvigationcontroller 打开)

第一组委托

@interface camera : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate,UIPopoverControllerDelegate>

从相机获取图像后

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
        {
            UIImagePickerController *imagePicker =
            [[UIImagePickerController alloc] init];
            imagePicker.delegate = self;
            imagePicker.sourceType =
            UIImagePickerControllerSourceTypeCamera;
            imagePicker.mediaTypes = [NSArray arrayWithObjects:
                                      (NSString *) kUTTypeImage,
                                      nil];

            imagePicker.allowsEditing = YES;

            imagePicker.wantsFullScreenLayout = YES;

            [self presentViewController:imagePicker animated:YES completion:nil];
            newMedia = YES;
            iscamera = 0;
        }
        else
        {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error to access Camera"
                                                            message:@""
                                                           delegate:nil
                                                  cancelButtonTitle:@"OK"
                                                  otherButtonTitles:nil];
            [alert show];

        }

&从图库中获取图像

 if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
    {
        UIImagePickerController *_picker=nil;
        if (popoverController) {
            [popoverController dismissPopoverAnimated:NO];

        }
        _picker = [[UIImagePickerController alloc] init];
        _picker.delegate = self;        
        _picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        _picker.wantsFullScreenLayout = YES;

        //[popoverController presentPopoverFromBarButtonItem:sender
                               //   permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {

           [self presentViewController:_picker animated:YES completion:nil];


        } else
        {
            popoverController = [[UIPopoverController alloc] initWithContentViewController:_picker];
            [popoverController setDelegate:self];
            [popoverController presentPopoverFromRect:btn.frame
                                               inView:self.view
                             permittedArrowDirections:UIPopoverArrowDirectionLeft
                                             animated:YES];
        }
    }
    else
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error access photo library"
                                                        message:@"your device non support photo library"
                                                       delegate:nil
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles:nil];
        [alert show];

    }

您在委托方法中获得的两个结果

-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{

}
于 2012-12-29T06:42:21.690 回答