EKEventStore eventStore: var?
@IBAction func bbbbbbb(sender: UIButton) {
if eventStore == nil {
eventStore = EKEventStore()
}
self.eventStore?.requestAccessToEntityType(EKEntityType.Event, completion: { (aBool, error) -> Void in
print(error, aBool)
})
}打印结果为零,始终为假...它的行为就像用户已经拒绝了访问,但提示永远不会显示。当然,相同的代码可以在相同设备上的新空白应用程序中运行。我尝试过的事情:在设备上休息设置,模拟器,使用一个从未安装过应用程序的新设备,当然还有清理项目,但没有成功。另外,在应用程序设置中,日历权限也没有显示出来。你知道是怎么回事吗?
发布于 2016-09-30 23:30:43
使用iOS 10时,您需要在plist中添加以下密钥,以允许应用程序访问日历(否则,应用程序将在请求访问时崩溃):
key: "Privacy - Calendars Usage Description"
value: "$(PRODUCT_NAME) calendar events"请看这里:
https://iosdevcenters.blogspot.com/2016/09/infoplist-privacy-settings-in-ios-10.html
发布于 2016-09-26 06:30:17
尝试以下代码
let eventStore = EKEventStore()
eventStore.requestAccessToEntityType(EKEntityType.Event) { (granted: Bool, error: NSError?) -> Void in
if granted{
print("Got access")
let defaultCalendar = eventStore.defaultCalendarForNewEvents
print("\(defaultCalendar.calendarIdentifier)")
}else{
print("The app is not permitted to access reminders, make sure to grant permission in the settings and try again")
}
}https://stackoverflow.com/questions/33902113
复制相似问题