关键字:ALAssetsLibraryErrorDomain 3312
ALAssetsLibraryErrorDomain 3311
ALAssetsLibraryAccessUserDeniedError ALAssetsLibraryAccessGloballyDeniedError
当程序访问系统相册的图片,或使用定位服务的时候,如果用户关闭了全局定位服务,或者关闭了我们程序定位服务,那么我们程序访问相册将会失败。
比如使用
- (void)enumerateGroupsWithTypes:(ALAssetsGroupType)types usingBlock:(ALAssetsLibraryGroupsEnumerationResultsBlock)enumerationBlock failureBlock:(ALAssetsLibraryAccessFailureBlock)failureBlock;
访问相册,会在failureBlock中返回error。
可以使用以下代码来确认是否能访问。
注意
authorizationStatus 这个函数需要os4。2
if ([CLLocationManager locationServicesEnabled] &&
[CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized )
{
//Do ALAssetLibrary work here...
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:
NSLocalizedString( @"Please Enable Location Service's", @"Please Enable Location Service's" )
message: NSLocalizedString( @"Message", @"Message" )
delegate: self
cancelButtonTitle: NSLocalizedString( @"Close", @"Close" )
otherButtonTitles: nil];
[alert show];
}