2
votes

I have button in application i want that when user click on that button then it should show the unselected question labels text to red color

Only one lable text is changing of the Q1 only not the others.

-(IBAction)nextButtonClicked
{
    if ([professionLabel.text isEqualToString:@"Profession"]) 
    {    
        errorLabel.text=@"Please Select the Highlighted Answers";
        Q1.textColor=[UIColor redColor];   
    }
    else if ([workLabel.text isEqualToString:@"Work"]) 
    {      
        errorLabel.text=@"Please Select the Highlighted Answers";
        Q2.textColor=[UIColor redColor];
    } 
    else if([yearLabel.text isEqualToString:@"Year"])
    {    
        errorLabel.text=@"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];
    } 
}
1
first Clear your basic concepts...Buntylm

1 Answers

0
votes

Try and remove the else from the else if, then it will go in all the conditions one by one .... Else if will imply that if one statement is satisfied then the others will be skipped by default.

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

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

errorLabel.text=@"Please Select the Highliteg Answers";
Q3.textColor=[UIColor redColor];
}