当iPhone的Messages应用程序上显示键盘时,如果用户开始从messages表格视图向下滑动,并继续进入键盘区域,键盘将开始关闭。如果他们在这个过程中上下移动手指,键盘也会随之移动。
苹果是通过私有API做到这一点的吗,还是有一种方法可以(我假设)通过手势识别器来控制键盘?
发布于 2012-02-20 06:29:53
发布于 2014-06-23 13:28:13
发布于 2016-01-23 22:34:27
幸运的是,苹果在UIScrollView上添加了方便的属性keyboardDismissMode,让你的生活变得更轻松。
现在,只需更改故事板上的一个属性,或者添加一行代码,您的应用程序就可以像Messages.app一样运行!
此属性使用新的UIScrollViewKeyboardDismissMode枚举。此枚举的可能值如下:
UIScrollViewKeyboardDismissModeNone // the keyboard is not dismissed automatically when scrolling
UIScrollViewKeyboardDismissModeOnDrag // dismisses the keyboard when a drag begins
UIScrollViewKeyboardDismissModeInteractive // the keyboard follows the dragging touch off screen, and may be pulled upward again to cancel the dismiss下面是要更改的Storyboard属性,以便在滚动时关闭键盘:

希望这能帮助你解决问题
https://stackoverflow.com/questions/7133463
复制相似问题