iOS13 UIViewController isModalInPresentation 在 ObjectiveC 中没有 setter 所以无法设置?
iOS13 UIViewController isModalInPresentation has no setter in ObjectiveC so cannot be set?
我正在尝试对我用 ObjectiveC 编写的应用程序进行一些更新以采用新的 iOS 13 功能。我正在研究以模态方式呈现 View 控制器的新方式的交互式解雇处理,在检测到我的控制器发生变化后,我希望停止交互式解雇并按照 Apple 的建议向用户呈现对话。尝试使用以下代码
self.isModalInPresentation = YES;
没有编译出现以下错误
No setter method 'setIsModalInPresentation:' for assignment to property
从我的 ObjectiveC 项目转到这个 属性 的实现去到 ObjectiveC header 属性 定义如下
// modalInPresentation is set on the view controller when you wish to force the presentation hosting the view controller into modal behavior. When this is active, the presentation will prevent interactive dismiss and ignore events outside of the presented view controller's bounds until this is set to NO.
@property (nonatomic, getter=isModalInPresentation) BOOL modalInPresentation API_AVAILABLE(ios(13.0));
查看 swift 项目中的同一个 属性 会发现以下 swift 定义
// modalInPresentation is set on the view controller when you wish to force the presentation hosting the view controller into modal behavior. When this is active, the presentation will prevent interactive dismiss and ignore events outside of the presented view controller's bounds until this is set to NO.
@available(iOS 13.0, *)
open var isModalInPresentation: Bool
这只是 Apple 对 ObjectiveC 源代码的疏忽吗?我找不到任何 setIsModalInPresentation 函数或通过 _isModalInPresentation 直接访问它。我已经有一段时间没有在 ObjectiveC 中做任何重要的工作了,所以我的语言知识已经生疏了,我是否应该在我的子类中合成 属性?由于已经实施了 getter,我什至不确定它是如何工作的。
我使用的是 Xcode 11.0,我想我可以看看这是否已在 Xcode/iOS 的更高版本中修复?
一如既往的帮助,干杯
试试这个:
self.modalInPresentation = YES;
如题中所述,定义如下,
@property (nonatomic, getter=isModalInPresentation) BOOL modalInPresentation;
这意味着您需要将其设置为self.modalInPresentation = YES;
。 isModalInPresentation
是 getter.
很高兴 API 可用性检查!
VSDrawViewController *drawViewController = [[VSDrawViewController alloc] init];
// .. setup delegate and stuff, if needed.
if (@available(iOS 13.0, *)) {
drawViewController.modalInPresentation = YES;
} else {
// Handle old iOS changes
}
我正在尝试对我用 ObjectiveC 编写的应用程序进行一些更新以采用新的 iOS 13 功能。我正在研究以模态方式呈现 View 控制器的新方式的交互式解雇处理,在检测到我的控制器发生变化后,我希望停止交互式解雇并按照 Apple 的建议向用户呈现对话。尝试使用以下代码
self.isModalInPresentation = YES;
没有编译出现以下错误
No setter method 'setIsModalInPresentation:' for assignment to property
从我的 ObjectiveC 项目转到这个 属性 的实现去到 ObjectiveC header 属性 定义如下
// modalInPresentation is set on the view controller when you wish to force the presentation hosting the view controller into modal behavior. When this is active, the presentation will prevent interactive dismiss and ignore events outside of the presented view controller's bounds until this is set to NO.
@property (nonatomic, getter=isModalInPresentation) BOOL modalInPresentation API_AVAILABLE(ios(13.0));
查看 swift 项目中的同一个 属性 会发现以下 swift 定义
// modalInPresentation is set on the view controller when you wish to force the presentation hosting the view controller into modal behavior. When this is active, the presentation will prevent interactive dismiss and ignore events outside of the presented view controller's bounds until this is set to NO.
@available(iOS 13.0, *)
open var isModalInPresentation: Bool
这只是 Apple 对 ObjectiveC 源代码的疏忽吗?我找不到任何 setIsModalInPresentation 函数或通过 _isModalInPresentation 直接访问它。我已经有一段时间没有在 ObjectiveC 中做任何重要的工作了,所以我的语言知识已经生疏了,我是否应该在我的子类中合成 属性?由于已经实施了 getter,我什至不确定它是如何工作的。
我使用的是 Xcode 11.0,我想我可以看看这是否已在 Xcode/iOS 的更高版本中修复?
一如既往的帮助,干杯
试试这个:
self.modalInPresentation = YES;
如题中所述,定义如下,
@property (nonatomic, getter=isModalInPresentation) BOOL modalInPresentation;
这意味着您需要将其设置为self.modalInPresentation = YES;
。 isModalInPresentation
是 getter.
很高兴 API 可用性检查!
VSDrawViewController *drawViewController = [[VSDrawViewController alloc] init];
// .. setup delegate and stuff, if needed.
if (@available(iOS 13.0, *)) {
drawViewController.modalInPresentation = YES;
} else {
// Handle old iOS changes
}