iOS10 开发适配系列(持续更新)
2016-08-04 本文已影响535人
半路出家的程序猿
说在前面:iOS10即将发布,想必各位developer又要以对待初恋般的姿态开始新一轮的版本适配和功能研发,本文将持续记录自己适配iOS10的过程。
1、访问用户资源权限:
iOS10对访问用户资源的权限控制更加严格(例如:打开相机、麦克风,访问相册、通讯录等),在原有代码级别询问用户是否同意的基础上,还需要在Info.plist中增加需要访问资源的声明,二者缺一不可,下面以访问用户相册为例,进行演示。
1)、首先需要在Info.plist中添加节点(如下图所示):

2)、代码实现部分(和之前没有变化):
- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent *)event
{
UIImagePickerController *testVC = [[UIImagePickerController alloc] init];
testVC.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:testVC animated:YES completion:nil];
}

