我正在尝试通过以下代码为 UIButton 设置 UIImage,但没有任何反应。我在 viewDidLoad 中设置这些。它显示的唯一方法是如果我使用情节提要并以这种方式设置图像。
- (void)viewDidLoad
{
...
[self.locateMeButton setFrame:CGRectMake(11, 11, 46, 46)];
[self.locateMeButton setImage:[UIImage imageNamed:@"locateme_disabled.png"] forState:UIControlStateDisabled];
[self.locateMeButton setImage:[UIImage imageNamed:@"locateme_active.png"] forState:UIControlStateHighlighted];
[self.locateMeButton setBackgroundImage:[UIImage imageNamed:@"locateme_normal.png"] forState:UIControlStateNormal];
...
}