Shri Shri - 1 year ago 107
Objective-C Question

How to add UIImagePickerController as a sub view instead of Modal View

I have a segment controller on one of my views and now on the 0th index of segment controller I want to add UIImagePickerController (for showing camera view to user) by adding as sub view and not by ModalViewController. Right now the view gets loaded but It does not show any camera view. I am able to show the camera view by presentModalViewController and passing its object.

Here's the code--



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

cameraView.sourceType = UIImagePickerControllerSourceTypeCamera;

cameraView.showsCameraControls = NO;

//[self presentModalViewController:cameraView animated:YES]; //Working

[self.view addSubview:cameraView.view]; // Not Working


[self.view addSubview:picker.view];
[picker viewWillAppear:YES]; // trickery to make it show
[picker viewDidAppear:YES];

You get a white bar at the top as side effect since UIImagePickerController is not intended to be used with it.