Select next row programmatically

129 Views Asked by At

How can I select the next row programmatically in iOS?

I have a nextButton on my view, and I want myTable to select the next row after clicking my nextButton.

[myTable selectRowAtIndexPath: ??????
                 animated:YES 
           scrollPosition:UITableViewScrollPositionMiddle];

is my code is correct?

1

There are 1 best solutions below

0
On BEST ANSWER

Create a variable with your current index of the table

long currentindex;

Create index path and select row as your code :

currentindex = currentindex +1;
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:currentindex inSection:0];
[myTable selectRowAtIndexPath: indexPath
                 animated:YES 
           scrollPosition:UITableViewScrollPositionMiddle];