大家好, 我是一个iPhone开发和Obj-C的新手。我正在我的应用程序中使用“ALAssetLibrary”从照片库中检索图像。 我发现如果调用方启用了位置服务,则“ALAssetPropertyLocation”属性键才可用。这是检索资产位置信息的关键,但我没有使用“ALAssetPropertyLocation”属性,而是只使用了 ALAssetPropertyURLs。
每当我尝试在新设备上部署我的应用程序时,都会弹出一条消息框,显示“需要定位服务..” 我能否隐藏“ALAssetPropertyLocation”属性?
如果有人能够以正确的方式协助我解决问题,并提供任何样例代码来启动我的项目,我将不胜感激。
谢谢您的帮助 :)
这是我的代码:
//Getting image url from dictionary according to the user input
NSURL *imageurl = [dict objectForKey: [youSaid text]];
//Getting asset from url
typedef void (^ALAssetsLibraryAssetForURLResultBlock)(ALAsset *asset);
typedef void (^ALAssetsLibraryAccessFailureBlock)(NSError *error);
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
ALAssetRepresentation *rep = [myasset defaultRepresentation];
CGImageRef iref = [rep fullResolutionImage];
//Setting asset image to image view according to the image url
[imageview setImage:[UIImage imageWithCGImage:iref]];
};
ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror)
{
NSLog(@"Error, cant get image - %@",[myerror localizedDescription]);
};
if(imageurl != nil)
{
ALAssetsLibrary *assetLibrary=[[ALAssetsLibrary alloc] init];
[assetLibrary assetForURL:imageurl resultBlock:resultblock failureBlock:failureblock];
}