我在ENUMS上遇到了麻烦,特别是UIImageOrientation to ALAssetOrientation
我试过:
var orientation : ALAssetOrientation = image.imageOrientation.toRaw()和
var orientation : ALAssetOrientation = image.imageOrientation as ALAssetOrientation知道该怎么做吗?
发布于 2014-08-04 18:53:12
在enumerations In typeIn.They In objective c或c enums.Enums本身声明为struct,并且它们没有关联的值,因为Int.So不认为迅速和目标c枚举相同。
使用下面的代码使用fromRaw制作fromRaw的枚举实例
var orientation : ALAssetOrientation = ALAssetOrientation.fromRaw(UIImage().imageOrientation.toRaw())!由于fromRaw返回的是可选的,如果它不是有效的原始值,它将返回零,所以在分配需要时,需要使用unwrap,或者可以使用var orientation : ALAssetOrientation!隐式可选。
请参阅快速文档
使用枚举的fromRaw方法尝试查找具有特定原始value.Not的枚举成员--但是,所有可能的Int值都会找到匹配的行星。因此,fromRaw方法返回一个可选的枚举成员。
在Xcode 6.1中编辑使用
var orientation : ALAssetOrientation = ALAssetOrientation(rawValue: UIImage().imageOrientation.rawValue)!发布于 2014-11-11 20:17:09
fromRaw已被ALAssetOrientation的初始化程序所取代。
ALAssetOrientation(rawValue: image.imageOrientation.rawValue)!https://stackoverflow.com/questions/25124972
复制相似问题