滚动的时候让键盘消失


使用UIScrollViewKeyboardDismissMode实现了Message app的行为
像Messages app一样在滚动的时候可以让键盘消失是一种非常好的体验。然而,将这种行为整合到你的app很难。幸运的是,苹果给UIScrollView添加了一个很好用的属性keyboardDismissMode,这样可以方便很多。
 
现在仅仅只需要在Storyboard中改变一个简单的属性,或者增加一行代码,你的app可以和办到和Messages app一样的事情了。
 
这个属性使用了新的UIScrollViewKeyboardDismissMode enum枚举类型。这个enum枚举类型可能的值如下:
  1. UIScrollViewKeyboardDismissModeNone        // the keyboard is not dismissed automatically when scrolling 
  2. UIScrollViewKeyboardDismissModeOnDrag      // dismisses the keyboard when a drag begins 
  3. UIScrollViewKeyboardDismissModeInteractive // the keyboard follows the dragging touch off screen, and may be
  4.  pulled upward again to cancel the dismiss 
 
以下是让键盘可以在滚动的时候消失需要设置的属性:
 
posted @ 2014-02-07 10:19  沙影无痕  阅读(248)  评论(0编辑  收藏  举报