Check index path is valid before scrolling

This commit is contained in:
ismailgulek
2021-09-22 11:04:56 +03:00
parent c26475ed17
commit 554230a2b1
@@ -431,7 +431,12 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
// Scroll table view to make the selected row appear at second position
NSInteger topCellIndexPathRow = currentSelectedCellIndexPath.row ? currentSelectedCellIndexPath.row - 1: currentSelectedCellIndexPath.row;
NSIndexPath* indexPath = [NSIndexPath indexPathForRow:topCellIndexPathRow inSection:currentSelectedCellIndexPath.section];
[self.recentsTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];
if ([self.recentsTableView vc_hasIndexPath:indexPath])
{
[self.recentsTableView scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionTop
animated:NO];
}
}
}
else