2012-09-18 64 views
0

如何將UIImagePickerViewController作爲子視圖添加到ipad中。如何將UIImagePickerViewController作爲子視圖添加到ipad中?

在iphone我用像我墊不工作這這個工作的罰款

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]; 

但同樣的方式。相機打開時,ipad正在全屏顯示。 我不想使用popoverview控制器。 請幫幫我嗎?

+0

http://stackoverflow.com/questions/9015155/how-to-use-uiimagepickercontroller-in-ipad –

回答

3

UIImagePickerController必須在iPad上呈現UIPopoverController

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]; 
} 
相關問題