ios - 如何通过点击其调暗 View 来关闭 UIPresentationController

标签 ios objective-c uiviewcontroller uikit uipresentationcontroller

我正在使用 UIPresentationController 来显示自定义模式。演示 Controller 有一个 UIView 调光 View ,在显示时动画进出。模式本身是一个添加到展示 Controller 容器中的 UIViewController

问题

我只能从嵌入式 UIViewController 调用 [self dismissViewControllerAnimated:NO completion:nil]。但是我不能从 UIPresentationController 做同样的事情。但这就是调暗 View 的地方。

我想避免向模式添加额外的不可见 View ,或者尽可能使用 NSNotificationCenter

如何通过点击其变暗 View 来关闭 UIPresentationController?是否有意义?可能吗?

最佳答案

好的,我找到了。您可以通过 self.presentedViewController

到达显示的 UIViewController 以关闭
[self.presentedViewController dismissViewControllerAnimated:YES completion:nil];

关于ios - 如何通过点击其调暗 View 来关闭 UIPresentationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34308425/

相关文章:

objective-c - 如何准确知道 ScrollView 滚动何时停止?

ios - 以编程方式模拟UITextField的键盘返回键

ios - [Objective-C]在不隐藏键盘的情况下编辑 UILabel

objective-c - 为什么我们在 Windows 上没有很多 Objective-C 开发人员

ios - 我如何管理可能无休止地将 View Controller 推送到导航 Controller 堆栈? iOS

ios - 如何动态设置 UITableView 的高度?

ios - 如何将 Touch ID 与登录凭据相关联?

ios - 向下滚动时 UISearchBar 不随 Tableview 移动

ios - 如果条件为真,如何转移到特定的 Storyboard?

ios - 如何组织 Controller 和 View (iOS)