【问题标题】:How do you scroll to the bottom of a tableView if you don't know how many rows it has?如果您不知道它有多少行,如何滚动到 tableView 的底部?
【发布时间】:2011-07-15 00:46:35
【问题描述】:

我知道我们可以使用以下方法在常规 UITableViewController 中滚动到 UITableView 的底部:

- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated

可以通过计算对象数组中有多少对象来找到 indexPath。但是,在three20..我们如何做同样的事情,因为我们没有在表中的对象数组?

【问题讨论】:

    标签: iphone objective-c ipad three20


    【解决方案1】:

    我不知道是否有什么使 three20 不同,但这应该适用于任何 UITableViewController 子类:

    - (void)scrollToBottom {
        NSInteger section = [self.tableView numberOfSections] - 1;
        NSInteger row = [self.tableView numberOfRowsInSection:section] - 1;
        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section];
        [self.tableView scrollToRowAtIndexPath:indexPath 
                              atScrollPosition:UITableViewScrollPositionMiddle 
                                      animated:YES];
    }
    

    【讨论】:

    • 谢谢!不知道 numberOfSections 和 numberOfRowsInSection 存在
    猜你喜欢
    • 2017-06-26
    • 1970-01-01
    • 1970-01-01
    • 2021-08-05
    • 1970-01-01
    • 2011-07-05
    • 2015-03-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多