sreenivas
sreenivas

Reputation: 401

How to add UIImagePickerViewController as a subview in ipad?

How to add UIImagePickerViewController as a subview in ipad.

in iphone i used like this this working fine

self.pick = [[UIImagePickerController alloc]init];
pick.delegate = self;
pick.sourceType = UIImagePickerControllerSourceTypeCamera;
pick.sourceType = UIImagePickerControllerCameraDeviceFront;
pick.showsCameraControls = NO;
CGRect rect = CGRectMake(0, 0, 200, 250);
pick.view.frame = rect;
UIView *cameraView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 200, 200)];   
[cameraView setBackgroundColor:[UIColor greenColor]];
[cameraView addSubview:pick.view];
[self.view addSubview:cameraView];
[pick viewWillAppear:YES];
[pick viewDidAppear:YES];
[pick release];

but same way i pad is not working. ipad is getting full view when camera is open. i don't want to use popoverview controller. pls help me?

Upvotes: 0

Views: 208

Answers (1)

Muhammad Adil
Muhammad Adil

Reputation: 300

UIImagePickerController must be presented with UIPopoverController on iPad.

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
    UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
    [popover presentPopoverFromRect:self.selectedImageView.bounds inView:self.selectedImageView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    self.popOver = popover;
} else {
    [self presentModalViewController:picker animated:YES];
}

Upvotes: 3

Related Questions