Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Chailon

macrumors newbie
Original poster
Sep 13, 2011
2
0
Good Afternoon,

I'm trying to deploy my application in the selection of a single line in UITableView, but when I select another row, the previous line is not clear. I'm using images to represent the selection of the lines. I've tried to make each user's selection table rows stay with the image of deselection, but got no success.
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath  {
    
	static NSString *EditCellIdentifier = @"EditCell";
    
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:EditCellIdentifier];
    
	if (cell == nil) {
        
		cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:EditCellIdentifier] autorelease];
        
		UILabel *label = [[UILabel alloc] initWithFrame:kLabelRect];
		label.tag = kCellLabelTag;
		[cell.contentView addSubview:label];
		[label release];
		
		UIImageView *imageView = [[UIImageView alloc] initWithImage:unselectedImage];
		imageView.frame = CGRectMake(5.0, 10.0, 23.0, 23.0);
		[cell.contentView addSubview:imageView];
		imageView.hidden = !inPseudoEditMode;
		imageView.tag = kCellImageViewTag;
		[imageView release];
	}
	
	[UIView beginAnimations:@"cell shift" context:nil];
    
	UIImageView *imageView = (UIImageView *)[cell.contentView viewWithTag:kCellImageViewTag];
    NSNumber *selected = [selectedArray objectAtIndex:[indexPath row]];
	imageView.image = ([selected boolValue]) ? selectedImage : unselectedImage;
	imageView.hidden = !inPseudoEditMode;
	[UIView commitAnimations];
    
	UILabel *label = (UILabel *)[cell.contentView viewWithTag:kCellLabelTag];
	label.text = [listOfItems objectAtIndex:[indexPath row]];
	label.frame = (inPseudoEditMode) ? kLabelIndentedRect : kLabelRect;
	label.opaque = NO;
	
	return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

[tv deselectRowAtIndexPath:indexPath animated:YES];
	
    if (inPseudoEditMode) {
        
		BOOL selected = [[selectedArray objectAtIndex:[indexPath row]] boolValue];
		[selectedArray replaceObjectAtIndex:[indexPath row] withObject:[NSNumber numberWithBool:!selected]];
		[tv reloadData];
	}
}
 
No codes permitted in this forum. Use the Code Sharing and Software Promos forum.
The iPad Apps forum is for discussion of applications offered in the App Store for the iPad, including iPad-only apps and universal apps. If an app hasn't yet been adapted for the iPad, we suggest that you use the iPhone and iPod touch Apps forum instead.

The separate Code Sharing and Software Promos forum is for
forum members to share family/friend codes for cooperative App Store apps.
developers of App Store apps to post promo codes for their applications.
developers of Mac OS X applications to offer free copies of their applications using serial numbers or other methods.
Posts made in the Code Sharing and Software Promos forum do not count toward users' post count totals. Code sharing or giveaway threads posted in this forum will be removed or moved to the Code Sharing and Software Promos forum. Please report duplicate threads for the same game or app to the moderators so they can merge or remove duplicate threads.

See Code Sharing and Software Promos: Rules and FAQ for additional details and the Announcement for discussion.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.