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

關(guān)閉 UIScrollView 中的鍵盤

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

問題描述

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

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 內(nèi)調(diào)用 removeKeyboard 函數(shù)(在主視圖控制器內(nèi)定義)方法.但是,這只會在正常觸摸時移除鍵盤,而不是在簡單地滾動視圖時.那么,在 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 及更高版本中實現(xiàn)此目標的最簡潔方法.

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

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

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

相關(guān)文檔推薦

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 觸發(fā) 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 個視圖控制器之間滑動)
主站蜘蛛池模板: 国产高清在线精品 | 亚洲精品国产a久久久久久 午夜影院网站 | h视频在线免费 | 天堂在线1| 欧一区 | 国产精品亚洲综合 | 在线视频一区二区三区 | 天天插天天狠天天透 | 午夜天堂精品久久久久 | 久久久久国色av免费观看性色 | av网站在线免费观看 | 日日干日日操 | 精品视频一区二区三区在线观看 | 91原创视频 | 一本一道久久a久久精品综合蜜臀 | 91精品国产综合久久婷婷香蕉 | 国产精品视频导航 | 日本一区二区高清不卡 | 涩涩视频在线看 | 久久久久国产精品一区 | 国产精品久久久亚洲 | 欧美精品久久久久久久久久 | 成人区精品 | 国精产品一区一区三区免费完 | 国产欧美一区二区三区免费 | 久草网站 | 亚洲一区二区在线视频 | 正在播放国产精品 | 午夜影院在线 | 欧美一级α片 | 久久天堂网 | 亚洲第一天堂无码专区 | 日韩视频免费 | 免费美女网站 | 欧美视频在线免费 | 亚州精品天堂中文字幕 | 精品日韩一区 | 亚洲精品视频免费观看 | 国产精品久久久久久久久免费高清 | 最近中文字幕在线视频1 | 欧美高清视频一区 |