2011-04-20 55 views
7

Possible Duplicate:
How can i avoid Location service in AlAssetLibrary? Can i retrieve files using AlAssetLibrary without using Location Service?如何避免AlassetLibrary的位置服务?

大家好, 我在iPhone开发和OBJ-C是一个新手。我在我的应用程序中使用“ALAssetLibrary”来从照片库中检索图像。 我确定了“ALAssetPropertyLocation”属性关键字仅当位置服务呼叫者启用。它是检索我没有使用“ALAssetPropertyLocation” Property.i我只使用ALAssetPropertyURLs的asset.But的位置信息的关键。

每当我尝试部署我的新设备的应用没有与消息的消息盒子“需要定位服务。” 可我能隐藏“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];  
} 

回答

6

启用 “定位服务” 是使用AssetsLibrary的要求。 原因是照片库中的任何照片/视频都可能包含地理数据。这一数据不仅可以通过ALAssetPropertyURLs,而且如果你读出从资产原始数据(通过使用的getBytes:fromOffset:长度:错误:ALAssetsRepresentation的方法)。因为无法从原始图像数据中去除地理元数据(如果位置服务被禁用),我猜想设计决定是为了使用AssetsLibrary而强制使用“定位服务”。

此要求可能会造成混乱给用户。所以你需要做两件事:

1)如果用户拒绝访问位置服务,则当你的应用需要这个访问时显示一条清晰的消息,并且该应用实际上不确定当前位置或任何GPS /数据。

2),显示效果清晰说明如何启用定位服务,一旦用户按压了“NO”的初始对话框。

干杯,

亨德里克

+0

位置服务强制性什么似乎像访问URL的照片/路径的唯一途径?这是虐待。 – AlvinfromDiaspar 2012-07-27 06:32:56

相关问题