我正在開發iOS應用程序(仍在學習),我有一個按鈕,它的工作原理類似於組合框:單擊它時會打開一個帶有表視圖的新場景,顯示單擊時返回到前一個場景並調用updatePartner:方法的元素。直到這一點,它工作得很好。但是,當我嘗試更新按鈕的圖像,它只是不更新它...圖片按鈕不更新(iPhone)
- (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];
}
任何幫助將被apreciated!
更新:我一直在圍繞這個,但還沒有想通了....我已經測試viewDidLoad中裏面的方法:同一類updatePartner的方法:和它的作品,它的當我從另一個班級調用它不起作用...請幫助!謝謝!
問候, 裏卡多Amendoeira
你這些圖片添加到項目中?圖像屬於正確的目標? – NeverBe
是的。並且我知道圖像在項目中起作用,因爲我以編程方式將圖像放在桌面視圖上(不是相同的圖像)。 –
而且它也不適用於案例(案例7)。 –