2014-10-01 115 views
2

剛剛下載的ELCImagePicker,現在我在ELCImagePickerController.mIOS ELCImagePicker從枚舉類型ALAssetOrientation不同枚舉類型UIImageOrientation隱式轉換

得到這個警告
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]; 
} 
} 
+0

你具有的Xcode版本的問題,和你所鏈接針對其SDK ? – 2014-10-01 05:43:30

+0

我正在使用最新版本的Xcode 6。我正在測試運行IOS7的iPhone 5s。 – SuperKevin 2014-10-01 05:53:57

+0

我實際上正在將我的設備更新到IOS8。不知道這會有所作爲,但只是想我會提到它。 – SuperKevin 2014-10-01 15:31:01

回答

4

爲了擺脫這種警告我更新的這段代碼:

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]; 
} 
+0

你在這裏得到了內存泄漏嗎? – 2016-08-02 06:05:10