I am working on an iPhone application where I have a UITableView that is populated with an XML feed via a URL.
Say, for example, three cells are full.
If I click on the first cell, nothing happens, but if I touch the second or third cell, it takes me to the second screen connected with the cell, and the same thing happens with other cells - do not click on it, click on another, and it will lead me to the second screen of the previous selected.
I had never happened before and am rather confused.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"UITableViewCell"]; } cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; LocationsItem *atm = [[locations atms] objectAtIndex:[indexPath row]]; [[cell textLabel] setText:[atm atmName]]; float distance = [[atm atmDistance] floatValue]; NSString *distanceString = [NSString stringWithFormat:@"%0.2f miles from current location", distance]; [[cell detailTextLabel] setText:distanceString]; return cell; } - (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; LocationsItem *atm = [[locations atms] objectAtIndex:[indexPath row]]; ATMDetailsController *detailsController = [[ATMDetailsController alloc] init]; [detailsController setCurrentATM: atm]; [[self navigationController] pushViewController:detailsController animated:YES]; }
Thanks Nick
source share