我正在使用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