2012-09-03 82 views
2

我已經在應用程序按鈕,我想,當該按鈕的用戶點擊,那麼它應該顯示未選擇的問題標籤文本紅色更改按鈕的的UILabel文本顏色單擊

只有一個拉布勒文本改變Q1的只有其他人沒有。

 
-(IBAction)nextButtonClicked 
{ 
    if ([professionLabel.text isEqualToString:@"Profession"]) 
    {  
     [email protected]"Please Select the Highlighted Answers"; 
     Q1.textColor=[UIColor redColor]; 
    } 
    else if ([workLabel.text isEqualToString:@"Work"]) 
    {  
     [email protected]"Please Select the Highlighted Answers"; 
     Q2.textColor=[UIColor redColor]; 
    } 
    else if([yearLabel.text isEqualToString:@"Year"]) 
    {  
     [email protected]"Please Select the Highlighted Answers"; 
     Q3.textColor=[UIColor redColor]; 
    } 
    else 
    { 
     [self submitSurveyAnswers]; 
     [self submitSurveyAnswersOne]; 
     [self submitSurveyAnswersTwo]; 
     OnlineViewController*targetController=[[OnlineViewController alloc]init]; 
     targetController.mynumber=mynumber; 
     [self.navigationController pushViewController:targetController animated:YES]; 
    } 
} 
+0

首先明確你的基本概念... – Buntylm

回答

0

嘗試,並從else if刪除else,那麼它會在所有的條件之一去了一個.... Else if將意味着,如果一個語句是滿足,那麼其他人將被默認跳過。

if ([professionLabel.text isEqualToString:@"Profession"]) { 
[email protected]"Please Select the Highliteg Answers"; 
Q1.textColor=[UIColor redColor]; 
} 

if ([workLabel.text isEqualToString:@"Work"]) { 
[email protected]"Please Select the Highliteg Answers"; 
Q2.textColor=[UIColor redColor]; 
} 
if([yearLabel.text isEqualToString:@"Year"]){ 

[email protected]"Please Select the Highliteg Answers"; 
Q3.textColor=[UIColor redColor]; 
} 
+0

感謝您的幫助 –

+0

歡迎您:) – IronManGill