我正在以编程方式打印标签,但无法将其从屏幕上移除。我试过了,removeFromSuperview
但没有一个有效。它一直停留在屏幕上,而我可以在调试中看到它传递的代码,如下面的代码所示。lbl1.hidden = YES;
lbl1= nil;
ELSE
我的问题在哪里?
-(void)reloadData
lbl1 = [[UILabel alloc] initWithFrame:CGRectMake(320, 530, 550, 200)];
if (result1 > result2 && al == YES)
{
lbl1.userInteractionEnabled = YES;
lbl1.text = @" Warning!! ";
lbl1.tag = 30;
lbl1.font = [UIFont fontWithName:@"Helvetica" size:18.0];
lbl1.textColor = [UIColor redColor];
lbl1.backgroundColor = [UIColor clearColor];
lbl1.lineBreakMode = NSLineBreakByWordWrapping;
lbl1.numberOfLines = 2;
[self addSubview:lbl1];
[lbl1 release];
}
else{
//Non of them is removing the label.
[lbl1 removeFromSuperview];
lbl1= nil;
lbl1.hidden = YES;
}