在我的IF語句中,它有點奇怪,導致每次我的代碼循環時,只有SLOT1被調用並顯示在我的調試器中,爲什麼?我的發言有問題嗎?謝謝。IF語句比較
choiceSlot1 = TRUE;
choiceSlot2 = TRUE;
choiceSlot3 = TRUE;
choiceSlot4 = TRUE;
if (slot1 != [(UIImageView*)[self.carousel1 currentItemView] tag] || twoSlot1 != [(UIImageView*)[self.carousel2 currentItemView] tag] || choiceSlot1) {
NSLog(@"Slot1");
choiceSlot1 = FALSE;
}
else if (slot2 != [(UIImageView*)[self.carousel1 currentItemView] tag] || twoSlot2 != [(UIImageView*)[self.carousel2 currentItemView] tag] || choiceSlot2) {
NSLog(@"Slot2");
choiceSlot2 = FALSE;
}
else if (slot3 != [carousel1 indexOfItemViewOrSubview:carousel1.superview] || twoSlot3 != [(UIImageView*)[self.carousel2 currentItemView] tag] || choiceSlot3) {
NSLog(@"Slot3");
choiceSlot3 = FALSE;
}
else if (slot4 != [(UIImageView*)[self.carousel1 currentItemView] tag] || twoSlot4 != [(UIImageView*)[self.carousel2 currentItemView] tag] || choiceSlot4) {
NSLog(@"Slot4");
choiceSlot4 = FALSE;
}
那麼,你將choiceSlot1設置爲true,所以它總是進入第一個if。 – borrrden
'choiceSlot1'始終爲TRUE .. – Kjuly
我應該如何處理if語句的其餘部分? – Bazinga