使用 SDK 4.0 自定义 UIImagePickerController 的问题

发布于 2024-09-07 14:23:01 字数 1194 浏览 2 评论 0原文

我正在尝试使用最新 SDK 4.0 中的资产库框架创建自己的 UIImagePickerController。代码如下:

-(void)viewDidLoad{

 [super viewDidLoad];

 groups = [[NSMutableArray alloc] init];
 ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc] init];
 NSUInteger groupTypes = ALAssetsGroupAlbum;

 ALAssetsLibraryGroupsEnumerationResultsBlock listGroupBlock = ^(ALAssetsGroup *group, BOOL *stop) {
  if (group)
   [groups addObject:group];
 };

 ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError *error) {
  NSString *errorTitle = [error localizedDescription];
  NSString *errorMessage = [error localizedRecoverySuggestion];
  NSString *errorFailureDesc = [error localizedFailureReason];

  NSLog(@"Error: %@, Suggestion: %@, Failure desc: %@", errorTitle, errorMessage, errorFailureDesc); 
 };

 [assetsLibrary enumerateGroupsWithTypes:groupTypes usingBlock:listGroupBlock failureBlock:failureBlock];
}

这里的问题是我收到一个错误,并且从 gorups 枚举器调用失败块。这是日志:

错误:全局拒绝访问

建议:这个设置可以 在首选项中更改。

失败描述:用户已拒绝所有 应用程序访问其媒体。

如 SDK 4.0 演示中所示,应该显示一条消息,表明应用程序想要访问相册,并且用户应该同意访问。我根本没有看到任何消息并收到上述错误。有人可以告诉我应该在首选项中更改哪些内容来解决问题吗?

谢谢, 维克托.

I'm trying to create own UIImagePickerController using Assets Library Framework from the latest SDK 4.0. Here's the code:

-(void)viewDidLoad{

 [super viewDidLoad];

 groups = [[NSMutableArray alloc] init];
 ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc] init];
 NSUInteger groupTypes = ALAssetsGroupAlbum;

 ALAssetsLibraryGroupsEnumerationResultsBlock listGroupBlock = ^(ALAssetsGroup *group, BOOL *stop) {
  if (group)
   [groups addObject:group];
 };

 ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError *error) {
  NSString *errorTitle = [error localizedDescription];
  NSString *errorMessage = [error localizedRecoverySuggestion];
  NSString *errorFailureDesc = [error localizedFailureReason];

  NSLog(@"Error: %@, Suggestion: %@, Failure desc: %@", errorTitle, errorMessage, errorFailureDesc); 
 };

 [assetsLibrary enumerateGroupsWithTypes:groupTypes usingBlock:listGroupBlock failureBlock:failureBlock];
}

The problem here is that I receive an error and the failure block is called from the gorups enumerator. Here's the log:

Error: Global denied access

Suggestion: This setting can be
changed in Preferences.

Failure desc: The user has denied all
applications access to their media.

As shown in the SDK 4.0 demonstrations there should be displayed a message that the application wants access to the photo albums and the user should grand access. I see no message at all and receive the error described above. Is there someone who can tell me what should be changed in the Preferences to solve the problem?

Thanks,
Viktor.

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

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

发布评论

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

评论(1

紧拥背影 2024-09-14 14:23:02

为了访问此信息,应打开位置服务!无需重置所有设置。在这种情况下,将出现允许访问对话框。

In order to access this information Location Serivices should be tunred ON!!! There is no need to reset all the settings. In this case the allow access dialog will appear.

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