Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/104.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UIImagePickerController启动了我自己的UINavigationController?_Iphone_Ios_Cocoa Touch_Uiimagepickercontroller - Fatal编程技术网

Iphone UIImagePickerController启动了我自己的UINavigationController?

Iphone UIImagePickerController启动了我自己的UINavigationController?,iphone,ios,cocoa-touch,uiimagepickercontroller,Iphone,Ios,Cocoa Touch,Uiimagepickercontroller,我正在尝试将UIImagePickerController设置为UIImagePickerController源类型照相机(即当它允许用户拍照时),并将其推到我自己的uiNavigationController上,但它不起作用(无法将UINavigationalController推到另一个UINavigationalController) 我想知道,是否有任何方法可以定制此摄像头模块的版本,就像您可以使用UIImagePickerControllerSourceTypePhotoLibrary

我正在尝试将
UIImagePickerController
设置为
UIImagePickerController源类型照相机(即当它允许用户拍照时),并将其推到我自己的
uiNavigationController
上,但它不起作用(无法将
UINavigationalController
推到另一个
UINavigationalController


我想知道,是否有任何方法可以定制此摄像头模块的版本,就像您可以使用
UIImagePickerControllerSourceTypePhotoLibrary
UIImagePickerController
使用
ALAssets
?我只是不想将摄像头作为模式视图弹出,而是想自己推它
UINavigationalController

您可以使用
AVFoundation
定制相机


请参阅如何使用AVFoundation。

我也遇到了同样的问题,但我用这种方法解决了

如果你拍照
1) 从摄像头(作为UINavigationcontroller打开) 2) 来自Gallery(适用于作为UIpopovercontroller打开的ipad和作为nvigationcontroller打开的iphone)

第一组委托

@interface camera : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate,UIPopoverControllerDelegate>
&从多媒体资料中获取图像

 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
{

}

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

正如普林斯所提到的,你最好的选择是使用AVFoundation创建你自己的基金会。缺点是(默认情况下)你会失去相机应用程序的一些不错的功能,比如触摸对焦、收缩缩放等,但这些都可以自己添加

查看这篇文章,它很好地解释了如何使用AVFoundation库,还向您展示了如何在相机屏幕上添加叠加等内容。然后,您可以在google/stackoverflow上轻松找到如何添加“点击聚焦”之类的内容:)

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

}