【问题标题】:Hiding the button隐藏按钮
【发布时间】:2014-10-09 05:50:18
【问题描述】:

我遇到了一个问题,我正在开发一个测验应用程序,这里我使用一个按钮的返回目的。在我的应用程序中,第一个问题我隐藏了返回按钮,遵循以下代码。

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

在这个应用程序中,我使用代码来回答下一个问题,

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

回到问题,

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

}

转到下一个问题后,显示返回按钮,但是当我想再次返回第一个问题时,我需要隐藏返回按钮,但这里显示。 这很简单,但我很困惑如何解决它,请您建议我。谢谢。

【问题讨论】:

  • 为什么不使用button.hidden = YESbutton.enabled = NO
  • 您是否为每个新问题都设置索引 +1?然后,您可以将每次后退按钮单击设为 -1。你能提供更多的代码吗?
  • 这里一切正常,但是当我遇到第一个问题时,我需要隐藏按钮。
  • button.hidden=YES 和 button.enabled=NO 不适用于 @Bhumit

标签: ios iphone if-statement uibutton


【解决方案1】:

如果你不回答第一个问题,你应该这样做,所以检查第 1 个问题:

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

并按照 cmets 中的建议使用 button.hidden = YES;button.enabled = YES

【讨论】:

    猜你喜欢
    • 2019-08-27
    • 2020-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-18
    • 2021-11-27
    • 1970-01-01
    • 2014-03-13
    相关资源
    最近更新 更多