我創建一個測驗應用程序,我想知道使用多個,而不是if語句,我可以做一個使用INT之間交替算法UIViews當您單擊一個UIButton。隨着多個if語句代碼將是這個樣子:創建算法從按下一個UIButton更改的UIView
IBAction NextQuestion; {
Question++; //QUESTION IS THE int FOR THE ALGORITHM.
if (Question==2) {
self.view = PlayView2; //PlayView2 is the UIView I'm switching to.
}
if (Question==3) {
self.view = PlayView3; //PlayView3 is the UIView I'm then switching to after the next object/UIButton is pressed.
}
等等...
的IBAction爲連接到多個UIButtons更改視圖。目標是我想改變UIView算法而不是多個如果語句感謝您的幫助!
如何將你的意見到一個數組,並得到0和array.count-1之間的隨機數?然後你可以得到你的視圖:'View = [array objectAtIndex:randomNumber];'。沒有,如果聲明需要任何。 – Jeremy 2012-03-11 15:57:59