隐藏按钮上的 IOS 键盘
<p><p>我想监控 IOS 上的键盘隐藏按钮并触发一个事件。我说的是:</p>
<p> <img src="/image/J5CyI.jpg" alt="ipad keyboard"/> </p>
<p>我只想在用户按下实际按钮时进行监控。我不希望键盘隐藏时的事件。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>用户键盘通知观察者.. </p>
<p><strong>对于 swift </strong> </p>
<pre><code>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")
}
</code></pre>
<p><strong>对于 Objective-C</strong> </p>
<pre><code>[ addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
// register for keyboard notifications
[ addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
</code></pre></p>
<p style="font-size: 20px;">关于隐藏按钮上的 IOS 键盘,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/30568238/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/30568238/
</a>
</p>
页:
[1]