如何避免 AassetLibrary 的定位服务?

发布于 2024-11-02 07:38:31 字数 1673 浏览 2 评论 0原文

可能的重复:
如何避免AlAssetLibrary 中的定位服务?我可以使用 AlAssetLibrary 检索文件而不使用定位服务吗?

大家好, 我是 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];      
}

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

Hi all,
I am a newbie in iphone development and obj-c. i am using "ALAssetLibrary" in my Application to retrieve images from Photo Library.
I identified that "ALAssetPropertyLocation"Property Key only available if location services are enabled for the caller. it is the key to retrieve the location information of the asset.But i am not using "ALAssetPropertyLocation"Property.i am using only ALAssetPropertyURLs.

whenever i am trying to deploy my Application in a new device there is a message box with the message "Location Service needed.."
can i able to hide the "ALAssetPropertyLocation"Property?

I would really appreciate if someone could assist me in the correct way to approach my problem, and if possible any sample code to get my started.

Thank You In Advance :)

this is my Code:

//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];      
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

有深☉意 2024-11-09 07:38:31

启用“位置服务”是使用 AssetsLibrary 的要求。
原因是照片库中的任何照片/视频都可能包含地理数据。该数据不仅可以通过 ALAssetPropertyURL 获得,还可以从资产中读取原始数据(通过使用 ALAssetsRepresentation 的 getBytes:fromOffset:length:error: 方法)。由于无法从原始图像数据中剥离地理元数据(如果位置服务被禁用),我猜设计决策是为了使用 AssetsLibrary 强制使用“位置服务”。

此要求可能会让用户感到困惑。因此,您需要做两件事:

1)如果用户拒绝访问位置服务,则在您的应用程序需要此访问权限时提供明确的消息,并且该应用程序实际上无法确定当前位置或任何 GPS/数据。

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

干杯,

亨德里克

enabling "location services "is a requirement for using the AssetsLibrary.
The reason is that any photos/videos in the Photo-Library might contain geodata. This data is not just available through ALAssetPropertyURLs, but also if you read out the raw data from the asset (by using the getBytes:fromOffset:length:error: Method of ALAssetsRepresentation). Cause there is no way to strip the geo metadata from the raw image data (in case location services are disabled), I guess the design decision was made to make "location services" mandatory for using the AssetsLibrary.

This requirement might be confusing to the user. So you need to do 2 things:

1) If the user denies access to location services, then present a clear message while your app needs this access and that the app does not actually determine the current position or any GPS/data.

2) Display clear instructions how to enable location services, once the user has pressed "NO" on the initial dialog.

Cheers,

Hendrik

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文