我不知道爲什麼。用法很正常。當UITableView發佈時UITableViewHeaderFooterView不會釋放
- 的RegisterClass forHeaderFooterViewReuseIdentifier在viewDidLoad中
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
僅此而已。但泄漏檢測器MLeaksFinder提醒UITableViewHeaderFooterView泄漏。在儀器分配摘要中,UITableViewHeaderFooterView在UITableView已經發布時被持久化。
這發生在iOS9和iOS10上。它沒有得到釋放的可能原因是什麼?
當然
的ARC顯示代碼
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if (self.dataSource.count == 0 || section != 0) {
return nil;
}
XXXHistoryHeader *view = [tableView dequeueReusableHeaderFooterViewWithIdentifier:[XXXHistoryHeader reuseIdentifier]];
view.frame = CGRectMake(0, 0, MZDApplicationFrame.size.width, 95);
return view;
}
我的表僅具有1個1段報頭。我已經嘗試過用零reuseIdentifier到初始化它不工作
@interface XXXHistoryHeader : UITableViewHeaderFooterView
@property (nonatomic, strong) UILabel *count;
@property (nonatomic, strong) UILabel *money;
- (void)setCount:(NSString *)count totalMoney:(NSString *)money;
+ (NSString *)reuseIdentifier;
@end
@implementation XXXHistoryHeader
+ (NSString *)reuseIdentifier
{
return NSStringFromClass(self);
}
- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithReuseIdentifier:reuseIdentifier];
if (self) {
//not important
}
return self;
}
- (void)setCount:(NSString *)count totalMoney:(NSString *)money
{
//not important
}
- (void)dealloc
{
NSLog(@"dealloc!!!");
}
@end
你需要證明你的viewForHeader – SeanLintern88