无法在横向视图中关闭 EKEventViewController
当我使用 EKEventViewController
在应用程序中打开日历事件时,使用下面的代码可以在模式视图中正确显示我的事件。
let eventModalVC = EKEventViewController()
eventModalVC.event = myEvent
eventModalVC.allowsEditing = true
present(eventModalVC, animated: true, completion: nil)
在纵向模式下(使用 iOS 15),我可以使用向下滑动手势来关闭模式。但是,当我更改为横向时,手势不起作用,并且也没有后退或取消按钮(就像 EKEventEditViewController 那样)。我找不到视图控制器的任何属性可以让我关闭它。
因此,用户要么被卡住,要么必须将设备切换为纵向模式。我该如何解决这个问题?
When I open a calendar event in my app using EKEventViewController
using the code below it correctly displays my event in a modal view.
let eventModalVC = EKEventViewController()
eventModalVC.event = myEvent
eventModalVC.allowsEditing = true
present(eventModalVC, animated: true, completion: nil)
In portrait mode (using iOS 15) I can dismiss the modal using a swipe-down gesture. However, when I change to landscape orientation, the gesture does not work, and there is no back or cancel button either (like there is for the EKEventEditViewController
). I could not find any property of the view controller that would enable me to dismiss it.
So the user is either stuck or has to turn the device into portrait mode. How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我希望 EKEventViewController 提供一种类似方便且直观的方法来在横向视图中将其关闭,就像在纵向视图中一样,但没有任何运气。
为了获得后退按钮,我现在将模态视图包含在其自己的导航控制器中。这会显示一个“完成”按钮(以及一个删除按钮)。这两个按钮都不会关闭视图。这可以通过在父视图控制器中实现 EKEventViewDelegate 来完成。
I was hoping that the EKEventViewController offers a similar convenient and intuitive way to dismiss it in landscape view as it does in portrait view but have not had any luck.
To get the back button I now enclosed my modal view in its own navigation controller. That reveals a "Done" button (as well as a delete button). Neither button dismisses the view. That can be done by implementing
EKEventViewDelegate
in the parent view controller.