Search code examples
iosiphoneobjective-cuilabelsubviews

Looking for text in a list of UILabel in subviews


I try to access to the text of my UILabels in subviews

for (UIView *myView in recognizer.view.subviews) {
     ...
            }

How can I check the text of my UILabels found in this research?

Thanks


Solution

  • Try:

    for (UIView *myView in recognizer.view.subviews) {
        if([myView isKindOfClass: [UILabel class]]){
            //check ur Label text here
            UILabel * myLabel = (UILabel *) myView;
            if ([myLabel.text isEqualToString: @"Your String"])
            {
                //GO For Ur Logic Here
            }
        } 
    }
    

    Hope it helps you.. happy coding :)