我有带有单元格图像的 tableView 我想在选择任何单元格时添加选择图像它工作正常但问题是首先选择第一行然后选择第一行然后选择 row2 然后选择 row2 和 row1 它应该只有 row2两者都不选。
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
cell = [self.tableView cellForRowAtIndexPath:indexPath];
if (indexPath.row==0) {
cell.imageView.image=[UIImage imageNamed:@"Activity2.png"];
}
else if(indexPath.row==1){
cell.imageView.image=[UIImage imageNamed:@"Catalog2.png"];
}
else{
cell.imageView.image=[UIImage imageNamed:@"Library2.png"];
}
NSUInteger row = indexPath.row;
[self.appDelegate.splitViewController viewWillDisappear:YES];
NSMutableArray *viewControllerArray=[[NSMutableArray alloc] initWithArray: [[self.appDelegate.splitViewController.viewControllers objectAtIndex:1] viewControllers]];
[viewControllerArray removeLastObject];
if (row == 0) {
self.firstDetailViewController=[[[FirstDetailViewController alloc] init]autorelease];
[viewControllerArray addObject:self.firstDetailViewController];
self.appDelegate.splitViewController.delegate = self.firstDetailViewController;
}
if (row == 1) {
self.secondDetailViewController=[[[SecondDetailViewController alloc]init]autorelease];
[viewControllerArray addObject:self.secondDetailViewController];
self.appDelegate.splitViewController.delegate = self.secondDetailViewController;
}
if (row == 2) {
self.myLearningViewController=[[[MyLearningViewController alloc]init]autorelease];
[viewControllerArray addObject:self.myLearningViewController];
self.appDelegate.splitViewController.delegate = self.myLearningViewController;
}
}