Well, as I say in the subject, my problem is that I'm selecting programmatically a cell on a tableview with the intention of perform, automatically, the associated segue. I have the code to do this on the viewWillAppear of the associated tableviewcontroller.
The result is that the cell is selected, but the segue is not performed. Do you know why?
By the moment I'm performing the segue programmatically on the viewWillAppear to solve the problem, but I'm curious about why the segue is not automatically performed if the cell is selected...
By the way. The segue must be ok because when I select the cell tapping it works properly.
More info: i'm working on a splitviewcontroller. Left side has the tableviewcontroller and the segue presents a viewcontroller on the right side
Thanks a lot!
Carlos
Related code:
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// Si no hay ninguna fila seleccionada, seleccionaremos la primera
// Obtenemos la fila seleccionada
NSIndexPath *filaSeleccionadaPath = [self.tableView indexPathForSelectedRow];
// Si no hay ninguna fila seleccionada
if (!filaSeleccionadaPath)
{
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
}
}
The documentation on UITableView
specifies:
Calling this method does not cause the delegate to receive a tableView:willSelectRowAtIndexPath: or tableView:didSelectRowAtIndexPath: message, nor will it send UITableViewSelectionDidChangeNotification notifications to observers.
thus it will not trigger any actions. If you are using segues, you might want to use performSegueWithIdentifier:sender:
on the UIViewController
class (most likely self
). You can specify an identifier and the sending element (most likely the cell).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With