問題描述
每個人都想在鍵盤彈出時移動 UITableView,但我正在尋找一種方法來禁用鍵盤彈出時對光標(biāo)的自動動畫.當(dāng)鍵盤彈出并導(dǎo)致 UITableView 滾動到光標(biāo)(以避免阻止它)時,我遇到了奇怪的抽搐/搖晃/不穩(wěn)定的滾動行為.
Everyone wants to move the UITableView when the keyboard pops up, but I'm looking for a way to disable the automatic animation to the cursor when the keyboard pops up. I'm experiencing an odd jerking / jolting / erratic scrolling behavior when the keyboard pops up and causes the UITableView to scroll to the cursor (to avoid blocking it).
我的每個 UITableView 單元格中都有一個 UITextView.鍵盤彈出時我沒有提交任何其他動畫.
Each of my UITableView cells has a UITextView in it. I don't commit any other animations when the keyboard pops up.
此時,我想完全禁用動畫并手動滾動到所需的 CGPoint.
At this point, I would like to disable the animation completely and manually scroll to a desired CGPoint.
謝謝!
推薦答案
自動滾動代碼駐留在tableViewController中,所以不能禁用自動滾動.您可以從 UIViewController 子類化并在其中使用 tableView,而不是從 UITableViewController 子類化.如果你愿意使用 UITableViewController 本身,你可以重寫 viewWillAppear 并且不要調(diào)用 [super viewWillAppear].
The automatic scrolling code resides in tableViewController, so auto-scrolling can't be disabled. Instead of subclassing from UITableViewController you can subclass from UIViewController and use a tableView inside it. If you are willing to use UITableViewController itself, you can override viewWillAppear and don't call [super viewWillAppear].
這篇關(guān)于iOS:當(dāng)鍵盤出現(xiàn)時禁用 UITableView 動畫的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!