簡體   English   中英

使用自定義鍵盤時,使UITableView滾動到正確的位置

[英]Making UITableView scroll to right location when using custom keyboard

我有一個UITableView,我需要使用一個自定義鍵盤,由於某些原因,我不能將其用作inputView。 因此,我的鍵盤視圖顯示為子視圖。 它的高度是260。我想滾動表格視圖,以便所選單元格的y位置始終在0到260之間。這可能嗎? 這是我目前正在嘗試的...(這在鍵盤課中)

-(void)showForCellAtIndexPath:(NSIndexPath*)indexPath{
[UIView beginAnimations:nil context:NULL];
self.view.frame = CGRectMake(0.0,220.0,320.0,260.0);
delegate.tableView.contentInset = UIEdgeInsetsMake(0.0,0.0,260.0,0.0);
delegate.tableView.scrollIndicatorInsets = delegate.tableView.contentInset;
delegate.view.frame = CGRectMake(0.0,-210.0, delegate.view.frame.size.width,delegate.view.frame.size.height);
[UIView commitAnimations];
[delegate.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];

}

希望您的幫助。 謝謝!

好吧...此解決方案有點像黑客,但是如果有人搜索並找到了此解決方案,我就不希望他們費盡心思來解決這個問題。

我所做的是將分組表格視圖第一部分的標題高度修改為較大(300px對我來說足夠大)。 然后,我更改了y插入(在我的情況下為-255),以便一切看起來都很正常。 當用戶選擇一個部分時,我會立即消除插圖,然后滾動到底部。然后,當用戶單擊“完成”時,我將重新添加插圖,這樣用戶就不必進行額外的滾動。

希望這對遇到相同問題的任何人有所幫助!

暫無
暫無

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

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