[英]UITableViewController scroll default behaviour
我正在使用UITableviewController和單元格中的textField和text視圖。 默認情況下,當我單擊文本字段時,tableviewcontroller向上滾動內容,讓我了解該字段的內容。 此默認行為非常有用,但是當我編輯textView時,我已經實現了帶有完成按鈕(inputAccessoryView)的工具欄。 當我從編輯textField切換到編輯textView時,這是一個問題,因為鍵盤的工具欄位於textView的上方。
我嘗試了很多解決方案,但對我沒有任何幫助。 我已經嘗試過這樣的事情: https : //developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html
但對我不起作用,因為我認為此行為已在UITableViewController中實現。
PS:UITableViewController是使用Interface Builder創建的。 我不知道這些信息是否有用。
如果將UITableViewController設置為實現UITextViewDelegate協議,則可以通過實現此方法來知道何時開始編輯textView:
- (void)textViewDidBeginEditing:(UITextView *)textView
{
//then you can scroll the tableview up so you can see the textView
[self.tableView setContentOffset:CGPointMake(0, /*height of your toolbar*/) animated:YES];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.