iOS: 键盘关闭表单对象 Swift
iOS: Keyboard close down form objects Swift
我有一个只有很少表单对象的登录屏幕控制器。当用户单击任何表单对象时,iOS 键盘会出现在我的 登录按钮
上
并且必须单击任何其他区域以关闭键盘,然后单击登录按钮进行登录。如何在键盘出现时向上滑动这些表单对象?
您可以这样设置通知:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:self.view.window];
并设置通知以隐藏键盘,如下所示:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:self.view.window];
然后调用这些函数并设置任何你想要的东西。就像显示键盘时向上移动视图动画和隐藏键盘时向下移动视图动画一样。您可以使用函数设置这些动画:animateWithDuration
我有一个只有很少表单对象的登录屏幕控制器。当用户单击任何表单对象时,iOS 键盘会出现在我的 登录按钮
上并且必须单击任何其他区域以关闭键盘,然后单击登录按钮进行登录。如何在键盘出现时向上滑动这些表单对象?
您可以这样设置通知:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:self.view.window];
并设置通知以隐藏键盘,如下所示:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:self.view.window];
然后调用这些函数并设置任何你想要的东西。就像显示键盘时向上移动视图动画和隐藏键盘时向下移动视图动画一样。您可以使用函数设置这些动画:animateWithDuration