Mar*_*kin 3 iphone xcode objective-c interface-builder
有没有办法检测拍摄图像时手机的方向?
我在UIView上有一个UIImageView,我正在使用UIImagePicker拍摄照片或从相机胶卷中选择一个.但是如果图像是以横向模式拍摄的,我想要检测到这一点并调整图像视图的大小以阻止图像被拉伸并看起来很愚蠢.
有谁知道这是否可行(我假设是这样,因为照片应用程序执行此操作)如果是这样,我将如何在代码/界面构建器设置中执行此操作?
您可以使用myImage.imageOrientation
,它将为您提供UIImageOrientation,
或者,如果由于某种原因,您希望直接在"imagePickerController:didFinishPickingMediaWithInfo:"方法中使用EXIF信息.
通过访问信息字典[info objectForKey:@"Orientation"] ;
注意:这与UIImageOrientation没有直接关系,相关性如下.
- (UIImageOrientation)orientationFromEXIF:(int)exif { UIImageOrientation newOrientation; switch (exif) { case 1: newOrientation = UIImageOrientationUp; break; case 3: newOrientation = UIImageOrientationDown; break; case 8: newOrientation = UIImageOrientationLeft; break; case 6: newOrientation = UIImageOrientationRight; break; case 2: newOrientation = UIImageOrientationUpMirrored; break; case 4: newOrientation = UIImageOrientationDownMirrored; break; case 5: newOrientation = UIImageOrientationLeftMirrored; break; case 7: newOrientation = UIImageOrientationRightMirrored; break; } return newOrientation; }
但你最好使用.imageOrientation
归档时间: |
|
查看次数: |
7605 次 |
最近记录: |