可能重复:
大家好,我是iphone开发和obj-c的新手。我在我的应用程序中使用"ALAssetLibrary“从照片库检索图像。我发现,只有在为调用方启用位置服务的情况下,"ALAssetPropertyLocation"Property密钥才可用。检索不使用“ALAssetPropertyURLs.”属性的asset.But的位置信息是关键。我只使用ALAssetPropertyLocation
每当我试图在一个新设备中部署我的应用程序时,就会有一个消息框,上面有消息“所需的位置服务”。我能隐藏“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];
}发布于 2011-05-05 09:58:06
启用“位置服务”是使用AssetsLibrary的一项要求。原因是照片库中的任何照片/视频都可能包含地理数据。这些数据不仅可以通过ALAssetPropertyURL获得,还可以通过从资产读取原始数据(通过使用getBytes: from asset :length:ALAssetsRepresentation的方法)。由于无法将geo元数据从原始图像数据中删除(在禁用位置服务的情况下),我猜设计决策是在使用AssetsLibrary时强制使用“位置服务”。
这一要求可能会使用户感到困惑。所以你需要做两件事:
1)如果用户拒绝访问位置服务,则在您的应用程序需要这种访问时给出一个明确的信息,并且应用程序并不实际确定当前位置或任何GPS/数据。
2)一旦用户在初始对话框上按下“否”,就会显示清楚的说明如何启用位置服务。
干杯,
亨德里克
https://stackoverflow.com/questions/5727875
复制相似问题