I have a table view which I've configured so that when the user taps the row, it will move to a new view based on the name of the particular cell. However, when I first click a cell it does nothing, and when I click the next cell, it will act as if I had clicked the first cell.
For example, I have Helmet, Stick and Gloves. If I press Helmet, nothing happens. Then, if I press Stick, it will do the didSelectRowAtIndexPath for the Helmet and not the Stick. Any suggestion as to why this is happening?
//Tapping to change on row
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSLog(@"%@", cell.textLabel.text);
if([cell.textLabel.text isEqualToString:@"Helmet"])
{
[self performSegueWithIdentifier:@"toHelmetView" sender:indexPath];
}
}
//Segue control, fetch helmet and send it
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"toHelmetView"])
{
// Fetch the selected object
//EquipmentCategory *o = [_frc objectAtIndexPath:[self.tableView indexPathForSelectedRow]];
// Configure the next view + controller
HelmetView *nextVC = (HelmetView *)segue.destinationViewController;
nextVC.title = @"Helmet";
nextVC.model = self.model;
nextVC.h = [self.model helmetForPlayer:self.p];
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…