views:

29

answers:

1

I use below code for change image of each segment in segmentedControl but doesn't work

How to do it?

First way:

[seg setImage:[UIImage imageNamed:@"1.png"] forSegmentAtIndex:0];
[seg setImage:[UIImage imageNamed:@"2.png"] forSegmentAtIndex:1];

Second way:

[seg insertSegmentWithImage:[UIImage imageNamed:@"1.png"] atIndex:0 animated:YES];

[seg insertSegmentWithImage:[UIImage imageNamed:@"2.png"] atIndex:1 animated:YES];

A: 

You code seems to be ok. If you have created the segment by using IB, check your the connections to the IBOutlet. Other possible case is that the images are broken. Try with another ones.

Jorge