gpt4 book ai didi

ios - KeyboardWillShowNotification

转载 作者:可可西里 更新时间:2023-11-01 05:04:38 24 4
gpt4 key购买 nike

我有一个 UIKeyboardWillShowNotificationUIKeyboardWillHideNotification 的观察者。

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];

一切正常,除非它在 ​​viewController 当前不可见时有效。

我尝试与 self.navigationcontroller.topViewController 进行比较,但是当我有一个模态视图时,这不起作用,因为 topViewController 是模态下方的 View Controller 。

最佳答案

如果您正在使用 UIViewController,当 View 在 viewWillAppear: 中可见时,您可以为键盘通知注册您的实例,然后在 View 隐藏在其中时取消注册viewWillDisappear:这样,当 View 不可见时您将不会收到通知。

希望这对您有所帮助!

关于ios - KeyboardWillShowNotification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16966443/

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