簡體   English   中英

UITableView無法滾動到最后一行

[英]UITableView Can't scroll to last Row

我有一個表視圖,其中設置了幾個不同的行,其中每行包含兩個UITextViews。 當用戶開始編輯文本視圖時,我希望將其所在的表格視圖單元格滾動到表格視圖的頂部。 要滾動,我正在使用:

[self.tableView scrollToRowAtIndexPath:indexPath
                          atScrollPosition:UITableViewScrollPositionTop
                                  animated:YES];

除最后兩行外,此方法工作正常,該行略微滾動了一點,但並非一直滾動到頂部。

我認為問題在於表格視圖的內容大小不足以允許滾動,但是我不知道如何以適當的方式進行調整。

任何幫助,將不勝感激。

提前致謝!

只需在viewDidLoad中調用此方法即可解決您的問題。

- (void)configureInsetsOfTableView
{
    CGFloat defaultSpacing=10.0f;

    [self.tableView setContentInset: UIEdgeInsetsMake(0.f, 0.f,   self.navigationController.navigationBar.bounds.size.height + [UIApplication sharedApplication].statusBarFrame.size.height +defaultSpacing, 0.f)];
    [self.tableView setScrollIndicatorInsets:UIEdgeInsetsMake(0.f, 0.f, self.navigationController.navigationBar.bounds.size.height +    [UIApplication sharedApplication].statusBarFrame.size.height +defaultSpacing, 0.f)];
}

暫無
暫無

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

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