views:

549

answers:

2

Hello

Is there any easy way to change the color of the "UITableViewCellAccessoryCheckmark" from standard blue to black? Or do i need to make a subclass of uitableviewcell and insert a imageview myself?

Thanks :-) Sebastian

+1  A: 

Hi As far as I know there is no way of doing this.

I ended up implementing a complete custom view for my accessoryView. It also makes it easier to change it upon user interaction and to decide the tappable area, which I often find way to small. I guess you could do with just a button if you have no need for different views.

I did a customView, placed a transparent button inside it. This view I add to the cell:

CustomDisclosureArea *disArea = [[CustomDisclosureArea alloc] init];
[disArea setFrame:CGRectMake(280.0f, 0.0f, 40.0f, 71.0f)];
[disArea setTag:DISCLOSURE_ID];
[disArea.emptyButton addTarget:self action:@selector(cellButtonHandler:event:) forControlEvents:UIControlEventTouchUpInside]; //this the button inside the view.
[cell.contentView addSubview:disArea];
[disArea switchToState:AreaStateBlank]; //I can set it to different states (blank, checkmark, empty etc.
[disArea release];

Now the method that gets called when the accessoryView is tapped is a little special because we need to know which cell was tapped.

- (void) cellButtonHandler:(id)sender event:(id)event {

    NSSet *touches = [event allTouches];
    UITouch *touch = [touches anyObject];
    CGPoint currentTouchPosition = [touch locationInView:self.tableView];
    NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint: currentTouchPosition];
}

But You end up with an NSIndexPath, which is the same as you would get in a didSelectRow or and accessoryButtonTapped method.

Hope this helps if You decide to make a custom accessoryView:)

RickiG
thank you a lot. Parts like these make me wonder why apple does not eat their own food and populates the accessoryView when i set the style. ;-)
Sebastian
A: 

I haven't tried it but it might be possible to simply interrogate the accessoryView property of the cell and find the checkmark and replace it with another image (it's almost certainly an image.) I think that cell style is just a default style tablecell with an image cell that holds the checkmark.

TechZen
accessoryView is nil if you don't explicitly set it by yourself.if set, then the accessoryType is ignored.
Sebastian
Bummer. I was hoping it might be more simple.
TechZen