我正在做一个小型益智游戏的应用程序。我简要描述了我的应用程序。
1.它包含添加详细信息屏幕,我保持10 TextFields
并且用户需要在该字段中输入我保持强制的数据。输入所有字段后,用户需要选择一个字段并需要按开始按钮将前进到下一个标签屏幕。
2.我保留了5个屏幕,其中包含所有屏幕中的标签。对于每个屏幕,如果用户选择的字段在那里,那么他按YES或如果用户字段不在那里他将按NO。就像我保持5个屏幕。
3.根据用户在哪里他按了YES,我通过该布尔变量取一个布尔变量,我正在找到用户选择的输出。
4.在最终屏幕中,我在标签中显示用户选择的值。
AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
if (delegate.updateFirstView == NO && delegate.updateSecondView == NO && delegate.updateThirdView ==NO && delegate.updateFourthView == NO && delegate.updateFifthView == NO)
{
myLabel.text = @"Wrong Selection";
}
else if (delegate.updateFirstView == YES && delegate.updateSecondView == YES && delegate.updateThirdView == YES && delegate.updateFourthView == YES && delegate.updateFifthView == YES)
{
myLabel.text = delegate.fifthString;
}
else if (delegate.updateFirstView == YES && delegate.updateSecondView == YES && delegate.updateThirdView == YES && delegate.updateFourthView == YES)
{
myLabel.text = delegate.fourthString;
}
else if (delegate.updateFirstView == YES && delegate.updateSecondView == YES && delegate.updateThirdView == YES)
{
myLabel.text = delegate.thirdString;
}
else if (delegate.updateFirstView == YES && delegate.updateFourthView == YES && delegate.updateFifthView == YES)
{
myLabel.text = delegate.tenthString;
}
else if (delegate.updateFirstView ==YES && delegate.updateSecondView == YES && delegate.updateFifthView ==YES)
{
myLabel.text = delegate.eighthString;
}
else if (delegate.updateFirstView == YES && delegate.updateSecondView == YES)
{
myLabel.text = delegate.secondString;
}
else if (delegate.updateSecondView == YES && delegate.updateFourthView == YES)
{
myLabel.text = delegate.sixthString;
}
else if (delegate.updateThirdView == YES && delegate.updateFourthView == YES)
{
myLabel.text = delegate.seventhString;
}
else if (delegate.updateFourthView == YES && delegate.updateFifthView == YES)
{
myLabel.text = delegate.ninthString;
}
else if (delegate.updateFirstView == YES)
{
myLabel.text = delegate.firstString;
NSLog(@"label name is %@",myLabel.text);
}
这里发生的是我的updateFirstView == YES,我正在比较这个。并且它显示相同的值。我想知道我的逻辑是否有任何问题。
帮助我在哪里做错误。谢谢!!
答案 0 :(得分:0)
问题在于你的条件:
else if (delegate.updateFirstView == YES && delegate.updateSecondView == YES && delegate.updateThirdView == YES)
{
myLabel.text = delegate.thirdString;
}
else if (delegate.updateFirstView == YES && delegate.updateFourthView == YES && delegate.updateFifthView == YES)
{
myLabel.text = delegate.tenthString;
}
这里如果updateFirstView,updateSecondView和updateThirdView为“YES”,则标签将显示thirdString的值,而不管updateFifthView的值是YES还是NO,因为程序将永远不会进入该块,因为此块之前的条件为true 。其他组合的情况也是如此。