简体   繁体   English

iOS图像,Photokit,图像方向

[英]iOS Images, photokit, image orientation

I am working on an iOS app using iOS 8 and the new PhotoKit, I iterate over user images and I am trying to find out via code whether an image is vertical or horizontal? 我正在使用iOS 8和新的PhotoKit在iOS应用程序上工作,我遍历用户图像,并且试图通过代码找出图像是垂直图像还是水平图像? is there a flag I can inspect on the asset? 我可以检查资产上的标志吗?

Probably not the best response but maybe it can help: 可能不是最好的响应,但它可能会有所帮助:

You can check if pixelWidth of PHAsset object is larger than pixelHeight to detect if it is horizontal or not. 您可以检查PHAsset对象的pixelWidth是否大于pixelHeight以检测其是否为水平。 You can also write category in order to provide a flag which is BOOL to make your code looks cleaner. 您还可以编写类别,以提供一个BOOL标志,以使您的代码看起来更简洁。

You can use requestImageForAsset:targetSize:contentMode:options:resultHandler: to request a image and get its orientation through imageOrientation property. 您可以使用requestImageForAsset:targetSize:contentMode:options:resultHandler:请求图像并通过imageOrientation属性获取其方向。 See the doc here requestImageForAsset . 参见文档requestImageForAsset

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM