簡體   English   中英

出現鍵盤時,UITableView的節腳正在移動

[英]Section footer of UITableView is moving when keyboard is appearing

我有一個帶有不同部分的UITableView。 每個部分都有自己的頁腳(出於設計原因,該行僅是一條灰線)。 單擊部分中的表視圖單元格時,將顯示AlertView和鍵盤(輸入密碼)。 但是,當鍵盤出現時,該部分的頁腳會被鍵盤向上推。 您可以在灰色背景的AlertView后面看到它。 看起來很丑。

我如何避免這種情況? 后台中的頁腳應保持原樣(在該部分的底部)。 有任何想法嗎?

為此有一個解決方法,當textFieldShouldBeginEditing時將tableView.sectionFooterHeight = 0設置tableView.sectionFooterHeight = 0

func textFieldShouldBeginEditing(textField: UITextField) -> Bool {
    tableView.beginUpdates()
    tableView.sectionFooterHeight = 0
    tableView.endUpdates()
    return true
}

func textFieldShouldEndEditing(textField: UITextField) -> Bool {
    tableView.beginUpdates()
    tableView.sectionFooterHeight = 100
    tableView.endUpdates()
    return true
}

確保您在viewDidLoad()使用tableView.sectionFooterHeight = 100而不是使用func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat來設置footerView的高度

暫無
暫無

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

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