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 th开发者_JAVA技巧e best practice?
[myLabel removeFromSuperview];
精彩评论