-3

我有 3 个按钮:

*.h: (全部用实心圆圈表示,表示已分配

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

*.m:

@synthesize FavouritesButton;
@synthesize AllButton;

和代码:

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

它不会改变图像!在其他视图上,我也做了同样的事情,他们工作了——这到底是什么?

我什至尝试设置不存在的图像:

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

谁能帮我解决这个问题?

4

3 回答 3

1

尝试这个,

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];
于 2013-10-31T06:47:22.877 回答
0

尝试类似的东西

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

并确保您的按钮类型是自定义的

于 2013-10-31T06:47:12.120 回答
0

您应该通过以下方式将图像分配给 UIButton:

[allButton setImage:[UIImage imageNamed:@"oisagiowgiow.png"] forState:UIControlStateNormal];
于 2013-10-31T06:47:55.277 回答