iOS 4.3上的cameraOverlayView问题 [英] cameraOverlayView problem on iOS 4.3

查看:123
本文介绍了iOS 4.3上的cameraOverlayView问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有cameraOverlayView的选择器控制器在摄像机视图中显示产品的图像。在应用叠加层之前调整产品图像的大小。
它适用于iOS 4.2,但在iOS 4.3上,产品图像显示为完整尺寸。

I'm using an picker Controller with a cameraOverlayView to display an image of a product in the camera view. The product image is resized before applying on the overlay. It works fine on iOS 4.2 but on iOS 4.3 the product image is displayed full size.

pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
UIImageView *imgView =  [[[UIImageView alloc] initWithImage:[UIImage imageNamed:produitAffiche.img_realite]] autorelease];

// Resize
if(imgView.frame.size.height == 480)
{
    //Portrait
    imgView.frame = CGRectMake(80.0f, 120.0f, 160.0f, 240.0f);
}
else
{
    // Landscape
    imgView.frame = CGRectMake(40.0f, 160.0f, 240.0f, 160.0f);
}

imgView.contentMode = UIViewContentModeCenter;
imgView.clipsToBounds = NO;
imgView.contentMode = UIViewContentModeScaleAspectFit;  

pickerController.cameraOverlayView = (UIView *) imgView;

我更改了用作叠加层的UIImageView的帧,但它仍然以320 * 480显示。
我知道cameraOverlayView已经在iOS 4.3中进行了修改,但我不知道改变了什么以及我需要做些什么来纠正我的应用程序。

I changed the frame of the UIImageView I use as overlay but it's still displayed at 320*480. I know that the cameraOverlayView have been modified in iOS 4.3 but I don't know what has changed and what I have to do to correct my application.

谢谢你的帮助。

推荐答案

在iOS 4.3中,叠加视图被拉伸到全屏。因为您将内容模式设置为宽高比适合,所以图像会被拉伸以适应新的视图大小,即320x480。

In iOS 4.3 the overlay view is stretched to full screen. Because you set the content mode to aspect fit, the image is stretched to fit the new view size which is 320x480.

您需要创建一个全屏的透明UIView,将imageview添加到该视图并使UIView成为新的叠加视图。

You need to make a transparent UIView that is fullscreen, add the imageview to that view and make the UIView the new overlay view.

UIView *fullscreenView = [[UIView alloc] initWithFrame:CGRectZero];
fullscreenView.backgroundColor = [UIColor clearColor];
....
 [fullscreenView addSubview:imgView];
pickerController.cameraOverlayView = fullscreenView;

这篇关于iOS 4.3上的cameraOverlayView问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆