久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

關閉 UIScrollView 中的鍵盤

Dismissing the keyboard in a UIScrollView(關閉 UIScrollView 中的鍵盤)
本文介紹了關閉 UIScrollView 中的鍵盤的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

好的,我在 UIScrollView 中有幾個 UITextFieldsUITextViews,我想將鍵盤設置為隨時消失scrollview 被觸摸或滾動(當然,當您在文本字段/視圖內觸摸時除外).

Alright, I have a couple of UITextFields and UITextViews inside a UIScrollView, and I'd like to set the keyboard to disappear whenever the scrollview is touched or scrolled (except when you touch down inside the text field/view, of course).

我目前的嘗試是將 UIScrollView 替換為子類,并將其設置為在 touchesBegan 內調用 removeKeyboard 函數(在主視圖控制器內定義)方法.但是,這只會在正常觸摸時移除鍵盤,而不是在簡單地滾動視圖時.那么,在 UIScrollView 中移除鍵盤的最佳方法是什么?

My current attempt at doing this is replacing the UIScrollView with a subclass, and setting it to call a removeKeyboard function (defined inside the main view controller) inside the touchesBegan method. However, this only removes the keyboard for a normal touch, not when the view is simply scrolled. So, what's the best way to remove the keyboard inside a UIScrollView?

提前感謝您的幫助.

推薦答案

這是在 iOS 7.0 及更高版本中實現此目標的最簡潔方法.

Here is the cleanest way to achieve this in iOS 7.0 and above.

scrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;

或者

scrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive;

在斯威夫特中:

scrollView.keyboardDismissMode = .onDrag

或者

scrollView.keyboardDismissMode = .interactive

這篇關于關閉 UIScrollView 中的鍵盤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to subclass UIScrollView and make the delegate property private(如何繼承 UIScrollView 并使委托屬性私有)
Swift - how to get last taken 3 photos from photo library?(Swift - 如何從照片庫中獲取最后拍攝的 3 張照片?)
Setting contentOffset programmatically triggers scrollViewDidScroll(以編程方式設置 contentOffset 觸發 scrollViewDidScroll)
why UIScrollView is leaving space from top in ios 6 and ios 7(為什么 UIScrollView 在 ios 6 和 ios 7 中從頂部留下空間)
UIScrollView pauses NSTimer while scrolling(UIScrollView 在滾動時暫停 NSTimer)
Setting up UIScrollView to swipe between 3 view controllers(設置 UIScrollView 在 3 個視圖控制器之間滑動)
主站蜘蛛池模板: 一区二区三区视频在线观看 | 久草网址 | 毛片一级片 | 影音先锋欧美资源 | 草草视频在线免费观看 | 国产在线一区二区 | 日韩三级 | 丁香久久 | 久草色视频 | 午夜精品久久久久久久99黑人 | 浮生影院免费观看中文版 | 久久久久久成人 | 一区二区三区欧美在线 | 国产91丝袜在线播放 | 亚洲欧美在线观看 | 日韩在线视频观看 | 国产在线观看一区 | 国产成人精品高清久久 | 久草综合在线视频 | 欧美三区 | 久久国产精品一区二区三区 | www.五月天婷婷.com | 亚洲av毛片 | 亚洲国产精品成人综合久久久 | 国产日韩一区二区三免费高清 | av电影一区 | av色站| 欧美激情视频一区二区三区在线播放 | 国产精品视频久久 | 一区二区福利视频 | 久久不射电影网 | 久久精品中文 | 午夜影院在线观看视频 | 国产视频一区在线 | 久久久久九九九女人毛片 | 丁香一区二区 | 欧美精品在线观看 | 99reav| 亚洲经典一区 | 欧产日产国产精品视频 | 精品国产91 |