2011-04-20 57 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

相關問題