Hello.
I'm developing an iPhone application.
I have a class that inherits from UIView. It has a method to add two UILabels and one UIImageView as subviews of the class. The UILabels and UIImageView are created and destroyed on that method.
When I release this custom class it fails on [super dealloc] call on its dealloc method.
The debugger shows this:
There is something related with UILabel dealloc or removing it from superview.
If I comment the [super dealloc]
no error occurs.
Any advice?
UPDATE
- (void)dealloc {
[super dealloc];
}
- (void)drawView:(ARCoordinate *)coordinate {
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, BOX_WIDTH, 20.0)];
[titleLabel setBackgroundColor: [UIColor colorWithWhite:.3 alpha:.8]];
[titleLabel setTextColor: [UIColor whiteColor]];
[titleLabel setTextAlignment: UITextAlignmentCenter];
[titleLabel setText: [coordinate title]];
[titleLabel sizeToFit];
[titleLabel setFrame: CGRectMake(BOX_WIDTH / 2.0 - [titleLabel bounds].size.width / 2.0 - 4.0,
0,
[titleLabel bounds].size.width + 8.0,
[titleLabel bounds].size.height + 8.0)];
UILabel *subTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, BOX_WIDTH, 20.0)];
[subTitleLabel setBackgroundColor: [UIColor colorWithWhite:.3 alpha:.8]];
[subTitleLabel setTextColor: [UIColor whiteColor]];
[subTitleLabel setTextAlignment: UITextAlignmentCenter];
[subTitleLabel setText: [coordinate subtitle]];
[subTitleLabel sizeToFit];
[subTitleLabel setFrame: CGRectMake(BOX_WIDTH / 2.0 - [subTitleLabel bounds].size.width / 2.0 - 4.0,
21.0,
[subTitleLabel bounds].size.width + 8.0,
[subTitleLabel bounds].size.height + 8.0)];
UIImageView *pointView = [[UIImageView alloc] initWithFrame:CGRectZero];
[pointView setImage: [UIImage imageNamed:@"location.png"]];
[pointView setFrame: CGRectMake((int)(BOX_WIDTH / 2.0 - [pointView image].size.width / 2.0), (int)(BOX_HEIGHT / 2.0 - [pointView image].size.height / 2.0), [pointView image].size.width, [pointView image].size.height)];
[self addSubview:titleLabel];
[self addSubview:subTitleLabel];
[self addSubview:pointView];
[self setBackgroundColor:[UIColor clearColor]];
[titleLabel release];
[subTitleLabel release];
[pointView release];
}