Ped*_*dro 2 objective-c nsindexpath ios
我想获取NSIndexPath部分中的行数.对于我在这里和Apple的文档中的所有搜索,我找不到如何获得这个值.有什么线索吗?
我的具体目的是使用它来确定所选行是否是该部分中的最后一行,因此如果有人建议通过另一种方法确定该行是一样好的话.
Ind*_*ore 10
一切都在文档中
int rows = [table numberOfRowsInSection:indexPath.section];
Run Code Online (Sandbox Code Playgroud)
唯一的方法是询问表的数据源:
NSUInteger rowCount = [tableView.dataSource tableView:tableView numberOfRowsInSection:indexPath.section];
Run Code Online (Sandbox Code Playgroud)
以下是我在我的案例中的表现:
表部分包含存储在其中的对象列表NSArray,因此节中的行数是数组中对象的数量.在你的情况下 - 如果row不是数组中的对象 - 只需进行检查
if ([indexPath row] + 1 == [_objectsArray count]) {
...
Run Code Online (Sandbox Code Playgroud)
但是,如果表中的项目未保存在集合中,则只需tableView在didSelectRow..委托方法中调用对象上的相应方法,即可轻松检索节中的行数:
NSInteger numberOfRows = [tableView numberOfRowsInSection:[indexPath section]];
Run Code Online (Sandbox Code Playgroud)