当我的用户点击我的tableview中的一个单元格时,它应该将它们推送到detailViewController。这种情况会发生,但由于某些原因,无论我的用户点击哪个单元格,detailView中都会显示相同的数据(它始终是最近添加的项目中的数据)?而不是每个单元格中显示的不同数据。知道为什么会这样吗?
OtherUserViewController.m
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSMutableArray *testPets = self.userPets;
if (tableView == self.otherPets) {
static NSString *PetTableIdentifier = @"PetsTableViewCell";
PetsTableViewCell *cell = (PetsTableViewCell *)[tableView dequeueReusableCellWithIdentifier:PetTableIdentifier];
if (cell == nil)
{
cell = [[PetsTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:PetTableIdentifier];
}
NSString *petDescrip = self.petresultArray[indexPath.row][@"aboutdog"];
cell.dogBio.text = petDescrip;
NSString *petName = self.petresultArray[indexPath.row][@"node_title"];
cell.petName.text = petName;
NSString *petBreed= self.petresultArray[indexPath.row][@"breed"];
cell.breedLabel.text = petBreed;
NSString *secondLink = self.petresultArray[indexPath.row][@"pet_photo_path"];
[cell.petImage sd_setImageWithURL:[NSURL URLWithString:secondLink]];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView == self.otherPets) {
PetViewController *detailViewController = [[PetViewController alloc]
initWithNibName:@"PetViewController" bundle:nil];
detailViewController.otherpetSubDetail = [self.userPets objectAtIndex:indexPath.row];
[self presentViewController:detailViewController animated:YES completion:nil];
}