2014-10-09 261 views
0

我有一个问题挣扎,我正在开发一个测验应用程序,在这里我使用一个按钮的目的。在我的应用程序的第一个问题,我隐藏后面的按钮,下面的代码。隐藏按钮

if ((questionIndex=1)) 
{ 
    backbutton.alpha=0; 
} 

在这个程序我用代码去下一个问题,

if (questionIndex < totalQuestionsCount - 1) { 
    [self loadQuestionsWithIndex:questionIndex + 1]; 
    questionIndex++; 
} 

,并回到刚才的问题,

if (questionIndex > totalQuestionsCount - 1) { 
    [self loadQuestionsWithIndex:questionIndex + 1]; 
    questionIndex--; 

}

去下一个问题后,后退按钮是显示,但是当我想再次回到第一个问题时,我需要后退按钮隐藏,但他这是展示。 这很简单,但我很困惑它如何修复可以请你建议我。谢谢。

+0

为什么不使用'button.hidden = YES'或'button.enabled = NO' – 2014-10-09 05:53:08

+0

你对每个新问题都建立索引+1吗?然后,您可以将它设置为-1,以便每回按钮单击一次。你能提供更多的代码吗? – 2014-10-09 05:56:42

+0

这里一切正常,但我需要隐藏按钮时,我在第一个问题。 – 2014-10-09 06:05:25

回答

0

对于即将备份,除非你谈到的第一个问题,你应该这样做,所以检查的第1题:

if (questionIndex > 0) { 
    [self loadQuestionsWithIndex:questionIndex + 1]; 
    questionIndex--; 
} 

,并请使用button.hidden = YES;button.enabled = YES在意见提出。