如何动态计算iPhone4,iPhone5和iPad的cameraViewTransform

时间:2014-02-14 13:25:15

标签: ios iphone objective-c ipad

如何动态设置不同iOS设备(iPhone4,iPhone5和iPad)的转换?

UIImagePickerController *pickerImage = [[UIImagePickerController alloc] init];
pickerImage.cameraViewTransform = ??

我是通过对iOS 7.0及更早版本的不同iOS设备(iPhone4,iPhone5和iPad)进行硬编码检查来实现的。

if (([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad))
{ // For iPad
    _pickerImage.cameraViewTransform = CGAffineTransformScale(_pickerImage.cameraViewTransform, 1.0, 1.0);
}
else
{ // For iPhone
    if ([UIScreen mainScreen].bounds.size.height == 568)
    { // iPhone5 ~ 4.0 inch
        if ([[[UIDevice currentDevice] systemVersion] floatValue] < 7.0)
            { // For older than iOS 7.0
                _pickerImage.cameraViewTransform = CGAffineTransformScale(_pickerImage.cameraViewTransform, 1, 1.4);                  
            }
            else
            { // For iOS 7.0 and later
                _pickerImage.cameraViewTransform = CGAffineTransformScale(_pickerImage.cameraViewTransform, 1, 1.67);                    
            }
    }
    else
    { // iPhone4 ~ 3.5 inch
        if ([[[UIDevice currentDevice] systemVersion] floatValue] < 7.0)
        {
            _pickerImage.cameraViewTransform = CGAffineTransformScale(_pickerImage.cameraViewTransform, 1.0, 1.25);
        }
        else
        { // For iOS 7.0 and later
            _pickerImage.cameraViewTransform = CGAffineTransformScale(_pickerImage.cameraViewTransform, 1.0, 1.0);
        }
    }
}

0 个答案:

没有答案