我正在尝试检查用户是否允许我的应用程序访问照片的权限(仅限Objective-C),但我收到以下错误:
Error 1: initializer element is not compile-time constant
Error 2: Excepted identifier or '('
以下是代码:
#import <UIKit/UIKit.h>
#import <AssetsLibrary/AssetsLibrary.h>
//(Error 1) ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
//(Error 2) if (status != ALAuthorizationStatusAuthorized) {
//show alert for asking the user to give permission
}
这些代码在我的.m文件中,如何解决此问题(请包含代码)?
答案 0 :(得分:0)
viewdidload
#import <UIKit/UIKit.h>
#import "BaseViewController.h"
#import <AssetsLibrary/AssetsLibrary.h>
@interface ViewController14 ()
@end
@implementation ViewController14
- (void)viewDidLoad
{
[super viewDidLoad];
ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
if (status != ALAuthorizationStatusAuthorized) {
//show alert for asking the user to give permission
}
}
@end