example if there is a method addLabel:
- (void)addLabel {
for (NSInteger i = 0; i < 5; i ++) {
UILabel *label = [[UILabel alloc] init];
[label setText:@"label"];
[[self view] addSubView:label];
[label release];
}
}
and the method is called whenever a button is fired.
Does it need to remove all the label from the subviews first (removeFromSuperView:) before addSubview again?
First, you have to give some coordinate to UILabel. So that, it can display at proper place.
You can use following line for that:
UILabel *lblTaskTitle = [[UILabel alloc] initWithFrame:CGRectMake(45.0, 5, 200.0, 35.0)];
Another thing is that, it will be better if you remove other label. (It’s not necessary, but it’s good practice).
You can do it in following way:
Hope it will be fine for you.
Let me know in case of any difficulty.