我正在为 iOS 开发一个应用程序(仍在学习),并且我有一个类似于组合框的按钮:单击它会打开一个带有表格视图的新场景,显示单击时返回到前一个场景的元素和调用updatePartner:方法。到目前为止,它工作得很好。但是当我尝试更新按钮的图像时,它并没有更新它......
- (void) updatePartner:(NSInteger)index
{
NSLog(@"updatePartner: %i", index);
NSString *partnerImage = @"";
UIImage *image = @"";
NSString *text = @"";
switch (index)
{
case 0:
partnerImage = @"ic_pcmedic_h45.png";
image = [UIImage imageNamed:partnerImage];
break;
case 1:
partnerImage = @"ic_sapo_h45.png";
image = [UIImage imageNamed:partnerImage];
break;
case 2:
partnerImage = @"ic_telepac_h45.png";
image = [UIImage imageNamed:partnerImage];
break;
case 3:
partnerImage = @"ic_meo_h45.png";
image = [UIImage imageNamed:partnerImage];
break;
case 4:
partnerImage = @"ic_zon_h45.png";
image = [UIImage imageNamed:partnerImage];
break;
case 5:
partnerImage = @"ic_caboviaso_h45.png";
image = [UIImage imageNamed:partnerImage];
break;
case 6:
partnerImage = @"ic_artelecom_h45.png";
image = [UIImage imageNamed:partnerImage];
break;
case 7:
text = @"Ainda não sou cliente";
break;
default:
break;
}
if (index <= 6)
[[self partnerButton] setImage:image forState:UIControlStateNormal];
else
[[self partnerButton] setTitle:text forState:UIControlStateNormal];
[[self partnerButton] setNeedsDisplay];
[[self view] setNeedsDisplay];
}
任何帮助将不胜感激!
更新:我一直在用这个,但仍然没有弄清楚....它不起作用......请帮助!谢谢!
问候,里卡多·阿门多埃拉