ios - 呈现 EKEventViewController
问题描述
我试图理解为什么我不能直接呈现 EKEventViewController() 而不将其转换为 UINavigationController。
如果我执行下面的代码,我会遇到错误“ Application tried to present modally a view controller <EKEventViewController: 0x11ecfd000> that has a parent view controller <UINavigationController: 0x11f39ea00>.
”:
let eventViewController = EKEventViewController()
eventViewController.delegate = self
eventViewController.event = event
eventViewController.allowsCalendarPreview = true
eventViewController.allowsEditing = true
if let topVC = UIApplication.shared.topMostViewController() {
topVC.present(eventViewController, animated: true, completion: nil)
}
但是,如果我将它添加到 UINavigationController,那么它会很好。
if let topVC = UIApplication.shared.topMostViewController() {
let navBar = UINavigationController(rootViewController: eventViewController)
topVC.present(navBar, animated: true, completion: nil)
}
只是想了解为什么“topVC.present(eventViewController,animated:true,completion:nil)”不起作用?
解决方案
推荐阅读
- javascript - 对如何使用 axios 正确处理 javascript 承诺有些困惑
- android - 当用户单击任何应用程序的卸载按钮时如何显示窗口
- c# - 从集合中过滤数据
- reactjs - 如何在 React Native 中加密数据(使用 Expo)
- math - 为什么我没有将十进制精度提高到 1 位?
- java - Java SHA-256 程序提供了错误的哈希
- c++ - C++ 中 Vector 的 std::upper_bound 和 std::lower_bound 的复杂性是多少?
- javascript - 我的 d3 折线图中的画笔功能未按预期工作
- node.js - 如果 www 不在反应 js Web 应用程序中的 URL 中,则将 www 添加到安全 URL
- jquery - 选择第一个元素的多选