0
在我的应用我创建一个临时对象,例如以下列方式标签:
UILabel *tempLabel = [ [UILabel alloc] initWithFrame: CGRectMake(100, 5, 200, 30)];
tempLabel.backgroundColor = [UIColor colorWithRed: 1.0f green: 1.0f blue: 1.0f alpha: 0.0f];
tempLabel.text = [ [WordsDatabase sharedWordsDatabase] dbName];
[ [self view] addSubview: tempLabel];
[tempLabel release];
这段代码被称为从viewWillAppear方法。
当视图本身第一次被调用时,一切都很好。但第二次,新标签似乎与旧标签重叠。
为了使这种效果消失,是否有任何步骤需要采取? 要添加到viewWillDisappear方法的东西?
我试图将标签声明添加到类接口中,并在viewWillDisappear方法中调用[label removeFromSuperview]。在这种情况下,一切都很好。 有没有办法做到这一点,而不存储对标签的引用?
预先感谢您。