键盘检测 [英] Keyboard Detection

查看:92
本文介绍了键盘检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在键盘出现时在我的应用程序中运行一个方法。
是否有预定义的方法或我必须创建它?
以及如何创建它?

I would like to run a method in my app when the keyboard shows up. Is there a predefined method or I have to create it? And how to create it?

推荐答案

您可以在键盘出现时收到通知:

You can have a notification when the keyboard is going to show up:

UIKeyboardWillShowNotification
UIKeyboardDidShowNotification

您可以像这样注册通知:

You can register the notification like this:

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

更多这里

这篇关于键盘检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆