簡體   English   中英

當鍵盤隱藏屏幕的下半部分時如何滾動 UITableView

[英]How to scroll UITableView When Keyboard hides the bottom half section of the screen

這是我的定制設計

我正在嘗試實現 2 個簡單的UITableView 第一個UITableView覆蓋屏幕的上半部分,第二個UITableView覆蓋屏幕的下半部分。 UITableView中的每個單元都有一個嵌入式 UITextField。 每當我 select (第二個 UITableView)底部文本框之一時,鍵盤向上滑動,但UITableView不滾動,並且鍵盤隱藏輸入字段和第二個UITableView

建議我在這種情況下該怎么做。 我只使用 2 UITableView

作為參考,請在下面找到圖片鏈接:

圖 1

圖 2

You need to use one UITableView and use TPKeyboardAvoidingTableView class for your UITableView this class automatically manages scrolling of UITextFields inside UITableViewCells . 您將在谷歌上獲得TPKeyboardAvoidingTableView的示例代碼搜索。

您是否嘗試過滾動視圖...??? 此鏈接可能對您有所幫助: http://www.edumobile.org/iphone/iphone-programming-tutorials/scrollview-example-in-iphone/

請使用 IQKeyboardManager 這將自動調整足夠的滾動,您必須將此代碼放在您的 AppDelegate 中:-

 import IQKeyboardManagerSwift
 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

  IQKeyboardManager.shared.enable = true

  return true
}

stackoverflow 上有與您的問題相關的答案。 試試這個: iPhone - 鍵盤隱藏文本字段

顯示鍵盤時更改 tableview 的高度,然后當它被關閉時重置高度。 希望這能回答你的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM