0
我只是瘋了構建和我的iPhone項目分析,和我從分析儀,它我不明白的警告,這是我的函數:對象,Biuld和分析潛在leask,viewForHeaderInSection
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
NSLog(@"user did select row at index: %d.%d", [indexPath section], [indexPath row]);
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__);
//UIView *customView;
if(section ==6){
UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(10.0, 0.0, 300.0, 36.0)];
UILabel * headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.opaque = NO;
headerLabel.textColor = [UIColor whiteColor];
headerLabel.highlightedTextColor = [UIColor whiteColor];
headerLabel.shadowColor = [UIColor blackColor];
headerLabel.shadowOffset = CGSizeMake(0, 1);
headerLabel.font = [UIFont boldSystemFontOfSize:13];
headerLabel.frame = CGRectMake(10.0, 0.0, 300.0, 30.0);
headerLabel.text = @"Personal Data";
[customView addSubview:headerLabel];
return customView;
}
if(section ==10){
UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(10.0, 0.0, 300.0, 36.0)];
UILabel * headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.opaque = NO;
headerLabel.textColor = [UIColor whiteColor];
headerLabel.highlightedTextColor = [UIColor whiteColor];
headerLabel.shadowColor = [UIColor blackColor];
headerLabel.shadowOffset = CGSizeMake(0, 1);
headerLabel.font = [UIFont boldSystemFontOfSize:13];
headerLabel.frame = CGRectMake(10.0, 0.0, 300.0, 30.0);
headerLabel.text = @"Actions";
[customView addSubview:headerLabel];
[headerLabel release];
return customView;
}
else {
return nil;
}
NSLog(@"<<< Leaving %s >>>", __PRETTY_FUNCTION__);
}
並且在返回customView的行中,分析器說: 「潛在的行###中分配的對象泄漏」,有人可以解釋爲什麼它發生了嗎?
感謝幫助
didSelectRowAtIndexPath函數與你所問的問題無關 - 爲什麼發佈它?在發佈代碼時,您應該格式化它 - 或者用4個空格縮進或選擇它,然後在問題編輯器中單擊「010101」按鈕 - 然後閱讀您的問題並幫助您更容易。 – Vladimir 2010-08-12 10:43:30