-3

I have 3 buttons:

*.h: (all are with filled circle, that means that they are assigned)

@property (strong, nonatomic) IBOutlet UIButton *AllButton;
@property (strong, nonatomic) IBOutlet UIButton *FavouritesButton;

*.m:

@synthesize FavouritesButton;
@synthesize AllButton;

and code:

AllButton.imageView.image =[UIImage imageNamed:@"list_top_icon_active-1.png"]; //image exists

And it doesn't change the image! On other View i did the same and they work - what the hell?

I even tried to set not existing image:

AllButton.imageView.image =[UIImage imageNamed:@"oisagiowgiow.png"]; //image doesn't exist - but no errors or crashes

Can anyone help me fix this?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Developer
  • 4,158
  • 5
  • 34
  • 66

3 Answers3

1

try this,

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(40, 140, 240, 30);
[button setTitle:@"title" forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:@"image.png"] forState:UIControlStateNormal];
shankar
  • 632
  • 4
  • 14
0

Try something like

[AllButton setImage:[UIImage imageNamed:@"list_top_icon_active-1.png"] forState:UIControlStateNormal];

and make sure your button type is custom

Surya Subenthiran
  • 2,217
  • 1
  • 15
  • 22
0

You should assign image to UIButton the following way:

[allButton setImage:[UIImage imageNamed:@"oisagiowgiow.png"] forState:UIControlStateNormal];
dariaa
  • 6,285
  • 4
  • 42
  • 58