2014-06-27 62 views
0

我創建了一個自定義視圖的相機覆蓋,我試圖通過應用比例和平移全屏相機。它在iPhone 5中工作得很好,但不在iPhone 5中。我嘗試了許多代碼部分,但仍未發現問題。這是我的代碼:iPhone 5s全屏相機

if ([[UIScreen mainScreen] bounds].size.height == 568) { 
    CGAffineTransform translate = CGAffineTransformMakeTranslation(0.0, 71.0); 
    CGAffineTransform scale = CGAffineTransformScale(translate, 1.333333, 1.333333); 
    imagePicker.cameraViewTransform = scale; 
} 

通過我做我的測試中的iOS 7

感謝的求助方式。

enter image description here

回答

0

,就把這行代碼在您的自定義相機oveylay類。它適用於iPhone5中的我。

 CGSize screenSize = [[UIScreen mainScreen] bounds].size; 

     int heightOffset = 120; 

     float cameraAspectRatio = 4.0/3.0; //! Note: 4.0 and 4.0 works 
     float imageWidth = floorf(screenSize.width * cameraAspectRatio); 
     float scale = ceilf(((screenSize.height + heightOffset)/imageWidth) * 10.0)/10.0; 

     self.imagePickerController.cameraViewTransform = CGAffineTransformMakeScale(scale, scale); 
+0

嗨。謝謝你的重播,但它仍然無法正常工作。我添加一個圖像來查看渲染。我不知道的是,它在iPhone 5中工作,而不是5s,即使它們具有相同的尺寸。 – aminovic09