//键盘出现 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardShow) name:UIKeyboardWillShowNotification object:nil]; //键盘消失 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardHide) name:UIKeyboardWillHideNotification object:nil]; - (IBAction)input:(UITextField *)sender { //创建一个线程用来延迟视图上弹 NSThread *thread = [[NSThread alloc]initWithTarget:self selector:@selector(change:) object:sender]; [thread start]; //释放创建的对象 }
//方法一: - (IBAction)input:(UITextField *)sender { //创建一个线程用来延迟视图上弹 NSThread *thread = [[NSThread alloc]initWithTarget:self selector:@selector(change:) object:sender]; [thread start]; //释放创建的对象 } - (IBAction)quxiao:(UIButton *)sender { [_textField resignFirstResponder]; NSThread *thread = [[NSThread alloc]initWithTarget:self selector:
IOS-监听系统键盘及键盘出现时候输入框向上移动
最新推荐文章于 2024-11-18 17:17:10 发布
本文介绍了如何在iOS应用中监听键盘的显示和隐藏,并通过示例代码展示了如何在键盘出现时使输入框跟随键盘上移,键盘隐藏时恢复原位的方法,包括两种不同的实现方式。
摘要由CSDN通过智能技术生成