开发者

UIImagePickerController within a UIView

I have a little iOS project/test i am performing where i am calling an UIImagePickerContoller with the source set to the iPhones camera.

I am wanting to load this "live" camera into a smaller UIVi开发者_运维百科ew box in my interface. I am getting the camera to load and show up, but not in the UIView. Here's the code I am working with :

- (void)viewDidAppear:(BOOL)animated {

    UIImagePickerController *scope = [[UIImagePickerController alloc] init];

    [scope setSourceType:UIImagePickerControllerSourceTypeCamera];
    [scope setShowsCameraControls:NO];
    [scope setEditing:NO];
    [scope setNavigationBarHidden:YES];

    [cameraDisplayView addSubview:scope.view];
    [scope viewWillAppear:YES];

    [super viewDidAppear:YES];
}


You need to use the cameraOverlayView property to draw other views on top of the camera view, not the other way around.

See the documentation for UIImagePickerController. You cannot force the camera picker controller into a UIView, you have to draw on top of the camera picker controller.

(And then you could set one of you overlaying views to clearColor to get a window to the camera controller.)


Set your imagepickercontroller frame size to your parent view like this:

scope.view.frame=CGRectMake(0, 0, cameraDisplayView.frame.size.width, cameraDisplayView.frame.size.height);

and than add your imagepickercontroller into your view.

[cameraDisplayView addSubview:scope.view];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜