gpt4 book ai didi

ios - presentedViewController 更改 KVO

转载 作者:技术小花猫 更新时间:2023-10-29 10:54:23 28 4
gpt4 key购买 nike

我正在尝试监听 presentedViewController 的更改,但看起来该属性不符合 KVO(或者至少我无法从中获取更改)。当 UIViewController 被主动呈现时,UIViewController 中有没有办法监听变化?

最佳答案

presentedViewController 似乎不符合 KVO,但可以通过覆盖 UIViewController 的相关呈现/解除方法来通知更改:

override func presentViewController(viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)?) {
// will present view controller
super.presentViewController(viewControllerToPresent, animated: flag, completion: completion)
}

override func dismissViewControllerAnimated(flag: Bool, completion: (() -> Void)?) {
super.dismissViewControllerAnimated(flag, completion: completion)
// did dismiss view controller
}

swift 4:

override func dismiss(animated flag: Bool, completion: (() -> Void)? = nil) {
...
}

关于ios - presentedViewController 更改 KVO,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19569615/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com