How to make the previous “label box” disappear and be released?
I release the object but it still just creates new “label boxes” on top of “label boxes” when I tap and move.
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesMoved:touches withEvent:event];
CGPoint nowPoint = [[touches anyObject] locationInView:self.view];
CGPoint prevPoint = [[touches anyObject] previousLocationInView:self.view];
CGRect RectFrame1;
RectFrame1 = CGRectMake(nowPoint.x, nowPoint.y, 280, 30);
UILabel *label = [[UILabel alloc] initWithFrame:RectFrame1];
label.text = [NSString stringWithFormat:@"x %f y %f", nowPoint.x, nowPoint.y];
label.backgroundColor = [UIColor blackColor];
label.textColor = [UIColor whiteColor];
[self.view addSubview:label];
[label release];
//[self release];
//[&RectFrame1 release];
}
If you want to remove it from the view use
removeFromSuperview