How to set Accessoryview on a static UITableViewCell?

I created a UITableViewController with a UITableView and a static UITableViewCells.

How can I change the appearance of an accessory to a custom image in UIImageView?

I know how to change the look of accessories in general:

UIImage *accessor = [UIImage imageNamed:@"imageName"];
[somecell setAccessoryView:[[UIImageView alloc] initWithImage: accessor]];

Decision:

Create an IBOutlet for each UITableViewCell that should have a custom accessory view and connect the IBOutlet to the UITableViewCell in the storyboard. After that, you can set the appearance of the accessory as shown above.

+5
source share
2 answers

I found a better solution:

  • Drag a view (e.g. an UISwitch instance) to the UITableViewController in the storyboard

    enter image description here

  • , . , accessoryView Outlets , 1.

    enter image description here

  • , . , UITableViewCell. , IBOutlet UISwitch , IBAction , UISwitch.

+15

UIButton

0

All Articles