hitting a next button for a UITableViewcell

I was wondering how I can realize the following:
Creating a next button and when it’s tapped the next UITableview row will be selected.

Since a picture is worth a thousand words I’ve added a screenshot.

  • how to display nested array data inside uitableview properly with Multiple level of Sections
  • YouTube videos inside UITableView iPhone App
  • Appending NSDictionary to other NSDictionary
  • UITableViewController inside a UIViewController
  • custom UITableView header similar to UISearchBar
  • iOS UITableView: what's the different between “cellForRowAtIndexPath” and “willDisplayCell: forRowAtIndexPath:”
  • http://img529.imageshack.us/img529/4341/picture5uuj.png

    As you can see below I added a toolbar and if I press the right button it has to select the next row. Any suggestions on how I can approach this ( I assume with some sort of iterator).

    ps. i want the row also to act as if it has been touched ( so i can put an action behind it )

    3 Solutions Collect From Internet About “hitting a next button for a UITableViewcell”

    Something like this should do the trick:

    - (void)selectNextRow
    {
      NSIndexPath *selectedRow = [self.tableView indexPathForSelectedRow];
      NSUInteger row = selectedRow.row;
      NSUInteger section = selectedRow.section;
      ++row;
      if(row >= [self.tableView numberOfRowsInSection:selectedRow.section])
      {
        row = 0;
        ++section;
        if(section >= [self.tableView numberOfSections])
        {
          row = 0;
          section = 0;
        }
      }
      NSIndexPath *rowToSelect = [self tableView:self.tableView willSelectRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:section]];
      [self.tableView selectRowAtIndexPath:rowToSelect animated:YES scrollPosition:UITableViewScrollPositionMiddle];
      [self tableView:self.tableView didSelectRowAtIndexPath:rowToSelect];
      // also, post notifications if desired
    }
    

    Perhaps there’s some complexity to your question that I’m missing, but you could simply track the selected row in your code and, when you get the event from the toolbar button, increment your selected row index and use the:

    -selectRowAtIndexPath:animated:scrollPosition:
    

    on your table to select the row?

    - (IBAction)btnClicked:(id)sender 
    {
        NSIndexPath *selectedRow = [self.MyTableview indexPathForSelectedRow];
        int i=selectedRow.row;
        i++;
    
        NSIndexPath* selectedCellIndexPath= [NSIndexPath indexPathForRow:i inSection:0];
        [MyTableview selectRowAtIndexPath:selectedCellIndexPath animated:false scrollPosition:UITableViewScrollPositionMiddle];
    }