0

I would like to set a custom image for all the UITableViewCell accessory view in my app. I've tried using this code:

[[UITableViewCell appearance] setAccessoryView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"table-arrow.png"]]];

but it doesn't work.

Any idea?

Claus
  • 5,662
  • 10
  • 77
  • 118

2 Answers2

3

Try creating custom appearance selector in UITableViewCell category. Here's an example implementation:

.h:

- (void)setAccessoryViewImage:(UIImage *)image UI_APPEARANCE_SELECTOR;

.m:

- (void)setAccessoryViewImage:(UIImage *)image {
    self.accessoryView = [[UIImageView alloc] initWithImage:image];
}

And than you can configure all your cells using proxy object:

[[UITableViewCell appearance] setAccessoryViewImage:[UIImage imageNamed:@"table-arrow.png"]];
Robert Wijas
  • 693
  • 7
  • 14
1

// try this

   cell.accessoryType = UITableViewCellAccessoryNone;
   UIImageView *imgArrow = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 10, 15)] ;
   imgArrow.image = [UIImage imageNamed:@"table-arrow.png"];
   cell.accessoryView = imgArrow;
   [imgArrow release];
   imgArrow = nil;
Lokesh Chowdary
  • 816
  • 5
  • 22
  • thanks for your answer but I need to do that using the Apperance Proxy in order to avoid performing this operation for each single screen controller in my app. – Claus Jul 03 '13 at 11:00