Я разрабатываю приложение для iPhone.
У меня есть класс, который наследуется от UIView . У него есть метод для добавления двух UILabels и одного UIImageView в качестве подпредставлений класса. UILabels и UIImageView создаются и уничтожаются с помощью этого метода.
Когда я выпускаю этот пользовательский класс, он завершается неудачно при вызове [super dealloc] для своего метода dealloc.
Отладчик показывает это:
альтернативный текст http://img339.imageshack.us/img339/3157/capturadepantalla201006s.png
Что-то связано с UILabel dealloc или удалением его из суперпредставления.
Если я прокомментирую [super dealloc]
, ошибки не возникнет.
Любой совет?
ОБНОВЛЕНИЕ
- (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];
}