Reputation: 43
Not really sure how to explain this but on my UITableView
I have a line of code that when I click on a cell it takes me to a new view which updates it's title based on the name of the cell. However when if I have two cells, one named 'One' and one named 'Two', when I click 'Two' it takes me to a view with title 'One' and vice versa. Any idea's to what may be causing this? Sorry I can't be of more help.
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
ACollection *newView = [[ACollection alloc] init];
newView.theTitle = [self.tableView cellForRowAtIndexPath:indexPath].textLabel.text;
[self.navigationController pushViewController:newView animated:YES];
}
Upvotes: 0
Views: 148
Reputation: 480
I think you have chosen wrong method for this
Just try this code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
ACollection *newView = [[ACollection alloc] init];
newView.theTitle = [self.tableView cellForRowAtIndexPath:indexPath].textLabel.text;
[self.navigationController pushViewController:newView animated:YES];
}
Upvotes: 1