UI进价iOS 干货整理iOS开发

iOS相册、相机、通讯录权限获取

2016-07-31  本文已影响6240人  wentianen

一、为什么要获取权限

在越来越注重个人隐私的今天,用户很多情况下希望自己能完全掌握自己手机应用对媒体信息的一些访问权限,比如相册、相机、通讯录等。苹果在iOS7、iOS8等几个系统版本对一些权限的控制都做了加强,需要用户授权后应用才有相关的访问权限。

场景:

二、权限状态说明

三、权限获取

  1. 相册权限
  1. 拍照权限
  1. 通讯录权限

{
/*! The user has not yet made a choice regarding whether the application may access contact data. /
CNAuthorizationStatusNotDetermined = 0,
/
! The application is not authorized to access contact data.
* The user cannot change this application’s status, possibly due to active restrictions such as parental controls being in place. /
CNAuthorizationStatusRestricted,
/
! The user explicitly denied access to contact data for the application. /
CNAuthorizationStatusDenied,
/
! The application is authorized to access contact data. */
CNAuthorizationStatusAuthorized
} NS_ENUM_AVAILABLE(10_11, 9_0);
```

四、拒绝授权的处理

五、简单封装示例

六、源码

完整源码

上一篇下一篇

猜你喜欢

热点阅读