我有一个具有1个部分的UITableView,而来自numberOfRows:NSMutableArray

我想在这里显示的是,每当UITableView出现时,滚动视图都必须滚动到最后一行。

为此,我要最后一行indexPath。如何获得?

我知道这个问题已经回答了很多次。但是这些方法都不适合我。

这是我尝试的代码

-(NSIndexPath*)lastIndexPath{
     NSInteger sectionsAmount = [myTableView numberOfSections];
     NSInteger rowsAmount = [myTableView numberOfRowsInSection:sectionsAmount-1];
     NSIndexPath *lastIndexPath = [NSIndexPath indexPathForRow:(rowsAmount - 1) inSection:(sectionsAmount - 1)];
     return lastIndexPath;
 }

最佳答案

由于您只有一个部分,因此yu可以找到带有

[NSIndexPath indexPathForRow:[yourArray count]-1 inSection:0]

关于ios - 获取UITableView中最后一行的索引路径,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25052142/

10-13 04:05