After adding a UILabel to my view, how do I delete it?
Posted
by Travis
on Stack Overflow
See other posts from Stack Overflow
or by Travis
Published on 2010-03-22T06:19:33Z
Indexed on
2010/03/22
6:21 UTC
Read the original article
Hit count: 318
iphone-sdk
|uilabel
I have added a UILabel to my view programmatically like this:
myLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 30.0f)];
myLabel.center = CGPointMake(160.0f, 120.0f);
myLabel.backgroundColor = [UIColor clearColor];
myLabel.textColor = [UIColor whiteColor];
myLabel.font = [UIFont fontWithName:@"Helvetica" size: 18.0];
myLabel.textAlignment = UITextAlignmentCenter;
myLabel.text = @"Hello";
[self.myView addSubview:myLabel];
To add a label to my view. What I can't seem to find out is once I'm done w/ the label (at a future point) how can I delete it from the view? [myLabel release]
doesn't seem to work which I think makes sense because the view it's added to probably retained it's over reference. So what is the best practice?
© Stack Overflow or respective owner