首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何避免来自AlassetLibrary的定位服务?

如何避免来自AlassetLibrary的定位服务?
EN

Stack Overflow用户
提问于 2011-04-20 09:01:34
回答 1查看 2.9K关注 0票数 7

可能重复:

How can i avoid Location service in AlAssetLibrary? Can i retrieve files using AlAssetLibrary without using Location Service?

大家好,我是iphone开发和obj-c的新手。我在我的应用程序中使用"ALAssetLibrary“从照片库检索图像。我发现,只有在为调用方启用位置服务的情况下,"ALAssetPropertyLocation"Property密钥才可用。检索不使用“ALAssetPropertyURLs.”属性的asset.But的位置信息是关键。我只使用ALAssetPropertyLocation

每当我试图在一个新设备中部署我的应用程序时,就会有一个消息框,上面有消息“所需的位置服务”。我能隐藏“ALAssetPropertyLocation”属性吗?

如果有人能以正确的方式帮助我解决我的问题,如果可能的话,我会非常感激,如果可能的话,任何样例代码都能让我开始工作。

(预先谢谢:)

这是我的代码:

代码语言:javascript
复制
//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];      
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-05-05 09:58:06

启用“位置服务”是使用AssetsLibrary的一项要求。原因是照片库中的任何照片/视频都可能包含地理数据。这些数据不仅可以通过ALAssetPropertyURL获得,还可以通过从资产读取原始数据(通过使用getBytes: from asset :length:ALAssetsRepresentation的方法)。由于无法将geo元数据从原始图像数据中删除(在禁用位置服务的情况下),我猜设计决策是在使用AssetsLibrary时强制使用“位置服务”。

这一要求可能会使用户感到困惑。所以你需要做两件事:

1)如果用户拒绝访问位置服务,则在您的应用程序需要这种访问时给出一个明确的信息,并且应用程序并不实际确定当前位置或任何GPS/数据。

2)一旦用户在初始对话框上按下“否”,就会显示清楚的说明如何启用位置服务。

干杯,

亨德里克

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5727875

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档