我如何避免从AlassetLibrary的位置服务? [英] How can i avoid location service from AlassetLibrary?

查看:148
本文介绍了我如何避免从AlassetLibrary的位置服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

b $ b我是iphone开发和obj-c的新手。我在我的应用程序中使用ALAssetLibrary从照片库中检索图像。
我确定 ALAssetPropertyLocation 属性键仅在调用者启用位置服务时可用。它是检索资产的位置信息的关键。但是我没有使用ALAssetPropertyLocationProperty.i只使用 ALAssetPropertyURLs

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.

我试图在一个新的设备部署我的应用程序有一个消息框,消息定位服务需要..
我可以隐藏ALAssetPropertyLocation属性?

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.

谢谢提前:)

这是我的代码:

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


推荐答案

启用位置服务使用AssetsLibrary的要求。
原因是照片库中的任何照片/视频可能包含地理数据。这些数据不仅可以通过ALAssetPropertyURLs获得,还可以从资产中读取原始数据(通过使用getAllSetsRepresentation的getBytes:fromOffset:length:error:Method)。因为没有办法从原始图像数据剥离地理元数据(如果位置服务被禁用),我想设计决定是使位置服务强制使用AssetsLibrary。

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)如果用户拒绝访问位置服务,则会在您的应用需要此访问权限时显示一条清除消息,实际上不确定当前位置或任何GPS /数据。

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)显示清楚的说明如何启用位置服务,一旦用户按下否​​ 。

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

干杯,

Hendrik

这篇关于我如何避免从AlassetLibrary的位置服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆