我的代码工作正常,当我打电话reloadData
方法每一秒,它消除了视图(当有视图),并添加子视图。问题是当没有子视图我得到exc_bad_access
问题,在[self.lbl1 removeFromSuperview]
函数上显示。removeFromSuperview当没有addSubView问题
我的代码
-(void)reloadData
if (result1 > result2 && al == YES)
{
lbl1 = [[[UILabel alloc] initWithFrame:CGRectMake(320, 530, 550, 200)] autorelease];
lbl1.userInteractionEnabled = NO;
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];
}
else if (result1 < result2 && al == YES){
[self.lbl1 removeFromSuperview];
}
请在那里将是我的问题?
它的工作原理,当我把所有带'SELF'的'lbl1'标签方法。感谢它现在的作品。 –