[英]UIGestureRecognizer in table view cell get indexPath always return the indexPath of the last cell
[英]How to find last but one indexPath cell of table view?
我需要保留表格視圖的最后一個indexPath單元格,並將其與當前的
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
方法。 我不知道該怎么辦。 我找到了有關上次選擇的單元格的答案,但對我沒有幫助。 如果有人有解決方案,請告訴我。
要在表視圖中保留最后一個indexPath的引用,請將此代碼添加到cellForRowAtIndexPath中:
if(indexPath == _indexPathReference)
{
//add your logic
}
...
...
if(indexPath.row == array.count - 1)
_indexPathReference = indexPath;
return cell;
希望這可以幫助!
您可以嘗試以下方法:
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:<Pass_Last_But_One_Row> inSection:<Pass_Correct_Section>]
這里,
Pass_Last_But_One_Row = cellDataModel.count-1;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.