0
我建立一個iPhone應用程序,其中我已經使用25個鍵按鈕的狀態,並且每個按鈕被示爲處於其正常mode.I的背景圖像還建立在另一個圖像突出顯示模式的按鈕。要改變從正常高亮顯示,並保持它的保持
最初按鈕將顯示在其正常模式 現在我希望,當按鈕被按下,然後按鈕應該改變爲其突出顯示的狀態,以便其他圖像將顯示在那裏。 我已經這樣做這樣做:
button.highlighted = YES;
它的工作,但它的套一小部分高亮顯示的圖像,然後再正常狀態下的按鈕的回來。我使用下面的代碼來創建按鈕。
for (int i=0; i<25; i++) {
if (i > 0) {
if (i%5 == 0) {
xaxis = 28;
yaxis = yaxis+42;
}
}
iconButton[i] = [UIButton buttonWithType:UIButtonTypeCustom];
iconButton[i].frame = CGRectMake(xaxis, yaxis, 50, 40);
[iconButton[i] setBackgroundImage:[iconArray objectAtIndex:random] forState:UIControlStateNormal];
[iconButton[i] setBackgroundImage:[tapedIconArray objectAtIndex:random] forState:UIControlStateHighlighted];
[iconButton[i] addTarget:self action:@selector(changeImage:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:iconButton[i]];
xaxis = xaxis+53;
}
我怎樣才能保持按鈕的狀態,我什至嘗試與計時器,但應用程序崩潰然後。 請幫我
許多在此先感謝
你可以發佈你如何創建按鈕的代碼並分配給它的圖像? – EmptyStack 2011-02-01 04:47:15
請把代碼中的問題將是比較容易找到溶液/錯誤 – 2011-02-01 04:50:37