0

I have a UITableView with many cells and all the cells are going into one xib view, i have 2 buttons in that xib view - Up, Down. What i want to do is to jump to the next/back cell content when pressing one of these buttons, the content view need to change, like Mail.app, Reeder app etc...

this is what i tried to do but it didn't work:

  NSIndexPath *currentPath = [tipsGuideViewTv indexPathForSelectedRow];
  NSIndexPath *nextPath = [NSIndexPath indexPathForRow:indexVariable.row+1         inSection:indexVariable.section];

 [self.navigationController popToViewController:nextPath animated:YES];

I search the web for solution but i didn't find exactly what i mean. Someone know how to made it?

Thanks.

Xtrician
  • 504
  • 3
  • 5
  • 14

1 Answers1

1
NSIndexPath *currentPath = [tipsGuideViewTv indexPathForSelectedRow];
NSIndexPath *nextPath    = [NSIndexPath indexPathForRow:currentPath.row+1 
                                              inSection:currentPath.section];

[tipsGuideViewTv selectRowAtIndexPath:nextPath animated:YES];

EDIT per comments

// To make it function the same as if they had tapped the row, do the following:
// Only call the methods that are implemented in your controller.
[tipsGuideViewTv tableView:tipsGuideViewTv willSelectRowAtIndexPath:nextPath];
[tipsGuideViewTv tableView:tipsGuideViewTv didSelectRowAtIndexPath:nextPath];

Make sure that the new index path is valid though (ie you aren't already t the end of the table).

lnafziger
  • 25,760
  • 8
  • 60
  • 101
  • If i go back to the UITableView from the view i see the next row selected, but i want to change the view to that next cell. Like the Mail.app, there is two arrow buttons that change the view to the next/back cell. I want to navigate to that cell via pushViewController – Xtrician May 01 '12 at 19:27