设置UIImagePickerController的帧大小和位置

时间:2013-01-17 17:14:16

标签: objective-c cocoa-touch uiimagepickercontroller

我试图在我的OverlayViewController中设置UIImagePickerController的框架到屏幕中间 - 我创建自定义按钮的地方:

self.imagePickerController.showsCameraControls = NO;
if ([[self.imagePickerController.cameraOverlayView subviews] count] ==0)
{
   CGRect overlayViewFrame = self.imagePickerController.cameraOverlayView.frame;
   CGRect newFrame = CGRectMake(0.0, CGRectGetHeight(overlayViewFrame)-self.view.frame.size.height-10.0, CGRectGetWidth(overlayViewFrame), self.view.frame.size.height + 10.0);
   self.view.frame = newFrame;
   [self.imagePickerController.cameraOverlayView addSubview:self.view];
   CGRect imagePickerControllerFrame = CGRectMake(0, topPanel.frame.size.height + 50, self.view.frame.size.width, self.view.frame.size.height - topPanel.frame.size.height - bottomPanel.frame.size.height);
   self.imagePickerController.view.frame = imagePickerControllerFrame;
}

但是,它会全屏打开,所选图像包括顶部和底部面板下方的区域。我希望它是一个矩形。

我从委托视图中显示UIImagePickerController,如下所示:

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

有什么问题?

1 个答案:

答案 0 :(得分:0)

来自UIViewController参考(link):

  

<强> presentViewController:动画:完成:

     

<强>讨论

     

在iPhone和iPod touch上,呈现的视图始终为全屏

如果您想嵌入图片选择器,则应手动将其视图添加到其他视图中。