CAN
CAN

Reputation: 1717

iOS 8 UILabel text is null issue

I have an issue in the iOS 8 with the UILabel. I am printing a text on the view while the text won't remove from the view if the result1 is bigger than the result2 while it is working fine in the iOS 7. And I have debugged and found that the label1.text is always null before I remove it from the screen. Please where would be my issue?

-(void)warningAlert{

    label1 = [[UILabel alloc] initWithFrame:CGRectMake(15, 85, 300, 660)];

    label1.backgroundColor = [UIColor clearColor];
    label1.textColor=[UIColor redColor];
    label1.numberOfLines=0;

    [self.view addSubview:label1];

        if (result1 < result2)
    {
        if (printed == NO) {

            label1.text = @"“Warning Warning!!”";

            printed = YES;
        }

    }
        else{

        NSLog(@"check the value %@", label1.text);

        [label1 removeFromSuperview];
        printed = NO;
    }

Upvotes: 0

Views: 289

Answers (1)

Rupesh
Rupesh

Reputation: 2051

Instead of adding and removing the label.

  1. Alloc the memory to label only once in viewDidlload
  2. And then Just hide or unhide the label.

Upvotes: 1

Related Questions