How can I tell if a UITableView contains a specific NSIndexPath?

前端 未结 8 1759
予麋鹿
予麋鹿 2021-02-07 06:27

Here is the code I\'m using:

if (appDelegate.currentMainIndexPath != nil /* && doesPathExistInTableView */)
{
    [tblView scrollToRowAtIndexPath:appDele         


        
8条回答
  •  逝去的感伤
    2021-02-07 07:19

    If you mean, 'is there a cell at index n' then you just have to compare the size of you datasource to n

    if (appDelegate.currentMainIndexPath != nil [datasource count] > n)
    {
        [tblView scrollToRowAtIndexPath:appDelegate.currentMainIndexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];
        appDelegate.currentMainIndexPath = nil;
    }
    

    Where datasource is for instance an NSArray.

提交回复
热议问题