2015-04-06 59 views
-4

我正在項目,,我在哪裏碰到了,我有一個按鈕和兩個圖像![1] 當我按下按鈕標籤應該改變爲+1爲目前圖像是選爲p圖像。 和缺席的標籤文本應改爲-1並繼續 幫助我任何一個這個。ios開發:單擊按鈕時,uilabel發生更改。

+0

你能否讓你的問題更清楚。 – Shruti 2015-04-06 09:43:54

+0

我有UIButton。當視圖出現時,它將背景圖像顯示爲absent.png。當我點擊相同的按鈕時,我得到的圖像是present.png,它被選中是。與此同時,當我按下按鈕時缺席標籤應該減少,並且應該將當前標籤值作爲一個增加。像智者一樣。 – 2015-04-06 10:47:27

回答

0

你可以有一個布爾

bool isPresent; 
int presentCount = 0; 
int absentCount = 0; 

viewDidLoad設置爲假

在按鈕按下方法

- (IBAction)button_pressed:(id)sender { 

if(isPresent == true){ 
// change your button image 
present count --; 
absentCount ++; 
// set this count on your label text 
} 
else{ 

present count ++; 
absentCount --; 
} 
} 

我希望我理解你的問題

現在這就是解決方案你正在尋找。

+0

感謝您的回答。我對ios很陌生,所以我不知道如何去質疑。反正再次感謝 – 2015-04-06 12:30:17

+0

@SantoshSugur。沒關係。沒問題。希望你能從我的鼻子裏得到一些幫助 – Shruti 2015-04-06 12:35:21