我正在使用UIImagePickerController和自定义叠加层构建应用程序。比较两幅图像(图像前和图像后)的作用是什么。在拍摄照片后,我正在使用前一张图片的自定义覆盖图(请参阅附图)。UIImagePickerController相机视图尺寸问题
iPhone 5 - ios7
iPhone 4 - iOS7(如果要拍摄的图像)
iPhone 4 - 的iOS 7(后拍摄照片)
见iPhone 4和iPhone 5相机视图之间的大小差异。
应用程序适用于iPhone 5的屏幕尺寸(iOS 6和ios7)。但iPhone 4/4s的屏幕尺寸,只有在iOS6下才能正常工作。问题是iPhone 4/4s(仅限ios7),相机视图需要全屏显示。这个意思是,你可以注意到 iPhone 5相机的视图大小〜320 * 427(iOS 6和iOS 7) iPhone 4相机的视图大小〜320 * 427(iOS 6) BUT iPhone 4相机的视图大小〜320 * 480 (IOS 7)。
图像拍摄后,它适合于320 * 427的实际尺寸。由于这个问题,我无法将图像与iPhone 4 iOS7上的相机视图对齐(因为它的尖叫声为320 * 480)。
有没有人面临这个奇怪的问题。我尝试了几乎所有的东西,但没有运气。请任何想法?
这是我的片段代码,用于在照片叠加之前加载自定义照相机视图。
- (void)loadCameraWithImage
{
if (!isLoadedOnce)
{
isLoadedOnce = YES;
UIImagePickerController *cameraView = [[UIImagePickerController alloc] init];
cameraView.sourceType = UIImagePickerControllerSourceTypeCamera;
cameraView.wantsFullScreenLayout = NO;
if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {
[self setEdgesForExtendedLayout:UIRectEdgeNone];
}
// crop before image
UIImage *imgTmpCropped = [self imageByCropping:imgBefore toRect:CGRectMake(0, 0, imgBefore.size.width/2, imgBefore.size.height)];
UIImage *overleyImage = [[UIImage alloc] initWithCGImage: imgTmpCropped.CGImage
scale: [UIScreen mainScreen].scale
orientation: UIImageOrientationDownMirrored];
UIImageView *crosshairView;
UIImageView *beforeView;
CGFloat screenHieght = [UIScreen mainScreen].bounds.size.height;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
//overleyImage = [UIImage imageNamed:@"overlay_ipad.png"];
crosshairView = [[UIImageView alloc] initWithImage:overleyImage];
crosshairView.frame = CGRectMake(0, 0, 768, 1024);
[crosshairView setUserInteractionEnabled:YES];
crosshairView.backgroundColor = [UIColor clearColor];
beforeView = [[UIImageView alloc] initWithImage:overleyImage];
beforeView.frame = CGRectMake(0, 0, 384, 1024);
beforeView.alpha = 0.5;
beforeView.contentMode = UIViewContentModeScaleAspectFill;
}
else {
//overleyImage = [UIImage imageNamed:@"overleyImageAfter.png"];
crosshairView = [[UIImageView alloc] init];
beforeView = [[UIImageView alloc] initWithImage:overleyImage];
if(screenHieght>500){
crosshairView.frame = CGRectMake(0, 60, 320, 480);
beforeView.frame = CGRectMake(0, 70, 160, 427);
}
else{
if([[[UIDevice currentDevice] systemVersion] floatValue] <7.0){
crosshairView.frame = CGRectMake(0, 0, 320, 480);
beforeView.frame = CGRectMake(0, 0, 160, 427);
}
else{
crosshairView.frame = CGRectMake(0, 0, 320, 480);
beforeView.frame = CGRectMake(0, 0, 160, 480);
}
}
[crosshairView setUserInteractionEnabled:YES];
crosshairView.backgroundColor = [UIColor clearColor];
beforeView.alpha = 0.5;
beforeView.contentMode = UIViewContentModeScaleToFill;
}
//[crosshairView addSubview:beforeView];
//set our custom overlay view
cameraView.cameraOverlayView = beforeView;
cameraView.delegate = (id)self;
cameraView.showsCameraControls = YES;
cameraView.navigationBarHidden = YES;
cameraView.toolbarHidden = YES;
[cameraView setHidesBottomBarWhenPushed:YES];
[self.view.window.rootViewController presentViewController:cameraView animated:YES completion:nil];
isLoadedOnce = NO;
}
}
您是否曾经能够为此找到解决方案?我面临类似的问题。 –
我可以解释这个问题。但你有没有找到解决办法? 随着iPhone 4(的iOS 7): 图像尺寸:{1936年,2592}这是你使用 “UIImagePickerControllerOriginalImage” 但 视图/窗口尺寸是挑选的UIImage从信息词典:{320,416}规模:2问题几乎是6.05倍,高度是6.23倍。所以当你看到这个图像时,它会被扭曲。 如果你发现了一些东西,你可以请分享?干杯 –
可悲的是没有解决方案。在我的项目中,我必须遵循这个限制 – sajaz