swift - 如何将 UIDropSession 用于 Apple 日历事件?
问题描述
开始实现拖放,大部分只是拖放,添加拖放图像、联系人、字符串在日历事件中被阻止
所以我的代码如下所示:
func addDropInteraction() {
let dropInteraction = UIDropInteraction(delegate: self)
view.addInteraction(dropInteraction)
}
public func dropInteraction(_ interaction: UIDropInteraction, canHandle session: UIDropSession) -> Bool {
return session.hasItemsConforming(toTypeIdentifiers: [kUTTypeCalendarEvent as String]) && session.items.count == 1
}
public func dropInteraction(_ interaction: UIDropInteraction, sessionDidUpdate session: UIDropSession) -> UIDropProposal {
return UIDropProposal(operation: .copy)
}
public func dropInteraction(_ interaction: UIDropInteraction, performDrop session: UIDropSession) {
}
唯一的问题是我在实现时无法加载类型的EKEvent
对象EKECalendarItem
:
session.loadObjects(ofClass: EKEvent.self) { eventItems in
let events = eventItems as! [EKEvent]
}
在performDrop session:
我收到一个错误:
Instance method 'loadObjects(ofClass:completion:)' requires that 'EKEvent' conform to '_ObjectiveCBridgeable'
所以我的问题是如何加载日历事件?
解决方案
推荐阅读
- vpn - Mojave 上的 Cisco Anyconnect VPN 出错
- excel - VBA在设置之前检查对象是否存在
- python - python如何支持字符串中的空字符?
- unit-testing - 使用 jest 测试 nuxt.js 应用程序时访问 `process.env` 属性
- php - 在 Woocommerce 单个产品页面上显示产品运输类别
- bash - 如何使用 CTRL+C 退出并杀死正在运行的 Docker 容器?
- java - Java 中的“java.lang.ArrayIndexOutOfBoundsException”错误
- sql - 使用 T-SQL 解析 URL 参数
- javascript - 使用 Vue JS 将“axios”传递给“Swiper”
- c++ - C++ 中的堆是包含类和结构对象还是只包含指针?