如何动态设置不同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);
}
}
}