gpt4 book ai didi

ios - EKEventeditViewController 在 iOS 13 上不会显示编辑按钮

转载 作者:行者123 更新时间:2023-11-28 23:26:20 25 4
gpt4 key购买 nike

我有一个简单的应用程序,我想在 EKEventViewController 中呈现一个事件。

    // the button action which validates if the event store access is granted and presents the given alert if true
@IBAction func actionButtonShowPopover(_ sender: Any) {
eventStore.requestAccess(to: .event) { (granted, _) in
guard granted else { return }

let event = self.generateAndSaveEvent()
self.presentEventViewController(withEvent: event)
}
}
    // creates and tries to save an sample even and returns it
private func generateAndSaveEvent() -> EKEvent {
let event = EKEvent(eventStore: eventStore)

event.title = "Event Title"
event.startDate = Date()
event.endDate = Date().addingTimeInterval(1800)
event.calendar = eventStore.defaultCalendarForNewEvents

do {
try eventStore.save(event, span: .thisEvent)
} catch(let error) {
print(error)
}

return event
}
    // displays an EKEventViewController with our newly created event within an popover
private func presentEventViewController(withEvent event: EKEvent) {
DispatchQueue.main.async {
let eventVC = EKEventViewController()

eventVC.event = event
eventVC.allowsEditing = true

eventVC.modalPresentationStyle = .popover
eventVC.popoverPresentationController?.sourceView = self.buttonShowPopover
eventVC.popoverPresentationController?.sourceRect = self.buttonShowPopover.frame.offsetBy(dx: 0, dy: -10)
eventVC.popoverPresentationController?.backgroundColor = .white
eventVC.popoverPresentationController?.permittedArrowDirections = .up

self.present(eventVC, animated: false, completion: nil)
}
}

我创建了一个事件,如上面的代码所示,并简单地在弹出 View Controller 中显示它。从 ios 13 开始,我得到了不同的结果:

iOS 12.4 with edit button

iOS 13 without edit button

我是否有可能遗漏 iOS12 -> iOS13 的更改?预先感谢 - 我很感激任何建议!

最佳答案

在 iOS 13 中编辑按钮已移至导航栏。您需要以无弹出样式的方式呈现它。

关于ios - EKEventeditViewController 在 iOS 13 上不会显示编辑按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58588288/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com