Я добавляю настраиваемое представление в tableHeaderView со следующим кодом:
imageButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
imageButton.frame = CGRectMake(120, 12, 64, 64);
imageButton.titleLabel.font = [UIFont systemFontOfSize:10];
imageButton.titleLabel.lineBreakMode = UILineBreakModeWordWrap;
imageButton.titleLabel.textAlignment = UITextAlignmentCenter;
[imageButton setTitle:NSLocalizedString(@"Choose\nPhoto", @"Choose\nPhoto") forState:UIControlStateNormal];
[imageButton addTarget:self action:@selector(photoButtonPressed) forControlEvents:UIControlEventTouchUpInside];
// add existing image, if any, to button
if (child.thumbnailImage != nil) {
[imageButton setBackgroundImage:child.thumbnailImage forState:UIControlStateNormal];
}
// add button to view
self.headerView = [[UIView alloc] initWithFrame:CGRectMake(22, 12, 70, 70)];
[headerView addSubview:imageButton];
// add view to table header
self.tableView.tableHeaderView = headerView;
Утечка памяти отображается в строке выделения выше для headerView UIView.
Я объявляю UIView и UIButton в заголовочном файле и освобождаю их в ViewDidUnload и dealloc, так что я не уверен, что делаю неправильно.
Кроме того, это отображается только на устройстве, а не на симуляторе (я думал, что упомяну).
Любая помощь будет оценена.
Спасибо
Rod