EKEventStore请求访问不起作用

Way*_*lli 1 calendar ios ekeventstore swift

var eventStore:EKEventStore?

@IBAction func bbbbbbb(sender: UIButton) {
        if eventStore == nil {
            eventStore = EKEventStore()
        }
        self.eventStore?.requestAccessToEntityType(EKEntityType.Event, completion: { (aBool, error) -> Void in
            print(error, aBool)
        })
}
Run Code Online (Sandbox Code Playgroud)

print是nil,false总是...它的行为就像用户已经拒绝访问,但promt永远不会被显示.相同的代码当然适用于同一设备上的新空白应用程序.我尝试过的事情:在设备上休息设置,模拟器并使用从未安装应用程序的新设备,当然还有清理项目,但没有成功.此外,在应用设置中,日历权限也不会显示.对于发生了什么的任何想法?

gta*_*ta8 5

使用iOS 10,您需要在您plist的应用中添加以下密钥以允许应用访问日历(如果不是,请求访问时应用只会崩溃):

key: "Privacy - Calendars Usage Description"
value: "$(PRODUCT_NAME) calendar events"
Run Code Online (Sandbox Code Playgroud)

看这里:

https://iosdevcenters.blogspot.com/2016/09/infoplist-privacy-settings-in-ios-10.html