gpt4 book ai didi

IOS ELCImagePicker 从枚举类型 ALAssetOrientation 到不同枚举类型 UIImageOrientation 的隐式转换

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:42:10 27 4
gpt4 key购买 nike

刚刚下载了 ELCImagePicker,我现在在 ELCImagePickerController.m 中收到此警告

Implicit conversion from enumeration type 'ALAssetOrientation' (aka 'enum ALAssetOrientation) to different enumeration type 'UIImageOrientation' (aka 'UIImageOrientation')

抛出警告的代码是:

orientation = [assetRep orientation];

这里是完整的函数,如果它更能说明问题的话:

- (void)selectedAssets:(NSArray *)assets
{
NSMutableArray *returnArray = [[NSMutableArray alloc] init];

for(ELCAsset *elcasset in assets) {
ALAsset *asset = elcasset.asset;
id obj = [asset valueForProperty:ALAssetPropertyType];
if (!obj) {
continue;
}
NSMutableDictionary *workingDictionary = [[NSMutableDictionary alloc] init];

CLLocation* wgs84Location = [asset valueForProperty:ALAssetPropertyLocation];
if (wgs84Location) {
[workingDictionary setObject:wgs84Location forKey:ALAssetPropertyLocation];
}

[workingDictionary setObject:obj forKey:UIImagePickerControllerMediaType];

//This method returns nil for assets from a shared photo stream that are not yet available locally. If the asset becomes available in the future, an ALAssetsLibraryChangedNotification notification is posted.
ALAssetRepresentation *assetRep = [asset defaultRepresentation];

if(assetRep != nil) {
if (_returnsImage) {
CGImageRef imgRef = nil;
//defaultRepresentation returns image as it appears in photo picker, rotated and sized,
//so use UIImageOrientationUp when creating our image below.
UIImageOrientation orientation = UIImageOrientationUp;

if (_returnsOriginalImage) {
imgRef = [assetRep fullResolutionImage];
orientation = [assetRep orientation];
} else {
imgRef = [assetRep fullScreenImage];
}
UIImage *img = [UIImage imageWithCGImage:imgRef
scale:1.0f
orientation:orientation];
[workingDictionary setObject:img forKey:UIImagePickerControllerOriginalImage];
}

[workingDictionary setObject:[[asset valueForProperty:ALAssetPropertyURLs] valueForKey:[[[asset valueForProperty:ALAssetPropertyURLs] allKeys] objectAtIndex:0]] forKey:UIImagePickerControllerReferenceURL];

[returnArray addObject:workingDictionary];
}

}
if (_imagePickerDelegate != nil && [_imagePickerDelegate respondsToSelector:@selector(elcImagePickerController:didFinishPickingMediaWithInfo:)]) {
[_imagePickerDelegate performSelector:@selector(elcImagePickerController:didFinishPickingMediaWithInfo:) withObject:self withObject:returnArray];
} else {
[self popToRootViewControllerAnimated:NO];
}
}

最佳答案

为了摆脱这个警告,我更新了这段代码:

if (_returnsOriginalImage) {
imgRef = [assetRep fullResolutionImage];
orientation = [assetRep orientation];
} else {
imgRef = [assetRep fullScreenImage];
}

以下内容:

if (_returnsOriginalImage) {
imgRef = [assetRep fullResolutionImage];

NSNumber *orientationValue = [asset valueForProperty:@"ALAssetPropertyOrientation"];
if (orientationValue != nil) {
orientation = [orientationValue intValue];
}

} else {
imgRef = [assetRep fullScreenImage];
}

关于IOS ELCImagePicker 从枚举类型 ALAssetOrientation 到不同枚举类型 UIImageOrientation 的隐式转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26134719/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com