Search code examples
iosxcodeuitableviewibaction

Use an IBAction to select and press a table cell row


I am trying desperately to make this IBAction just effectively press a cell at a selected row. I have managed to get it to select a row, but I can't work out how to effectively click on this cell! I am only making my first app but I have managed to figure most things out by myself, but just can't seem to find out how to do this, i'm hoping it is a simple solution (or there is a much better way to do it than I have).

Here is the code for my IBAction anyway:

- (IBAction)myButton:(id)sender {

// Specify which cell I wan't to select

NSIndexPath *myIP = [NSIndexPath indexPathForRow:0 inSection:0];

// Select it

[self.tableView selectRowAtIndexPath:myIP animated:NO scrollPosition:UITableViewScrollPositionTop];  

// Click this cell??

}

Thanks in advance for any help


Solution

  • Just tell the delegate that you've selected it

        [self tableView:self.tableView didSelectRowAtIndexPath:myIP];
    

    Assuming that self is your VC that controls the table.