gpt4 book ai didi

隐藏按钮上的 IOS 键盘

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:15:12 31 4
gpt4 key购买 nike

我想监控 IOS 上的键盘隐藏按钮并触发一个事件。我在说:

ipad keyboard

我只想在用户按下实际按钮时进行监控。我不想要键盘隐藏时的事件。

最佳答案

用户键盘通知观察者..

对于 swift

NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillAppear"), name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillHide"), name: UIKeyboardWillHideNotification, object: nil)


func keyboardWillAppear() {
println("Keyboard appeared")
}

func keyboardWillHide() {
println("Keyboard hidden")
}

针对 Objective-C

[[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
// register for keyboard notifications
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];

关于隐藏按钮上的 IOS 键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30568238/

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