在解雇uiimagepicker

时间:2015-07-06 11:44:05

标签: ios camera uiimagepickercontroller uiview-hierarchy

enter image description here 这是在crashlytics报道的一个问题。当我加载图像选择器并解散时,我得到了这个(我假设)。我只有这一次。但它与图像选择器或导航控制器有关。有人知道原因吗?

更新 图像选择器相机像这样加载。

    UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
    imagePickerController.modalPresentationStyle = UIModalPresentationFullScreen;
    imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
    imagePickerController.delegate = self;
    if([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft)
    {
        [[UIDevice currentDevice]setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeRight] forKey:ORIENTATION_STRING];
    } else {
        [[UIDevice currentDevice]setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:ORIENTATION_STRING];
    }

    self.imagePickerController = imagePickerController;
    [self.navigationController presentViewController:self.imagePickerController animated:YES completion:nil];

对于其他源类型,我使用以下代码。

UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = sourceType;
imagePickerController.delegate = self;
popOver = [[UIPopoverController alloc] initWithContentViewController:imagePickerController];
self.imagePickerController = imagePickerController;
popOver.delegate = self;
CGRect popOverRect = sender.frame;
[popOver presentPopoverFromRect:popOverRect
                         inView:self.view
       permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];

1 个答案:

答案 0 :(得分:0)

将UIIMagePickerController添加到ContainerView。 &安培;然后查看

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *)   kUTTypeMovie, nil];

[self addChildViewController:picker] ;

[picker didMoveToParentViewController:self] ;

[self.view addSubview:picker.view] ;

删除pickercontroller时

[picker.view removeFromSuperview] ;
[picker removeFromParentViewController] ;