Моя таблица состоит из двух разделов, и в первом разделе у меня все время нет элементов;
Я поместил это условие: if([tableView numberOfRowsInSection:section]<=0) return 0;
в мой метод viewForHeaderInSection
, но в мое приложениесумасшедший и приносит EXC_BAD_ACCESS
Вот мой настроенный headerView:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if([myTableView numberOfRowsInSection:section]<=0) return 0;
NSString *headerTitle = [titlesArray objectAtIndex:section];
UIView *customView = [ [ [UIView alloc] initWithFrame: CGRectMake(0.0, -5.0, 320.0, 25.0) ] autorelease ];
[customView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"myTableBackground.png"]]];
UIView *clearView = [ [ [ UIView alloc ] initWithFrame: CGRectMake(0.0, -5.0, 320.0, 25.0) ] autorelease ];
[clearView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:nil]]];
UIButton *button = [ [ [ UIButton alloc ] initWithFrame: CGRectMake(-9.0, 5.0, 320, 27.0) ] autorelease ];
button.tag = section;
[button setImage:[UIImage imageNamed:@"header_section_background.png" ] forState: UIControlStateNormal ];
button.highlighted = NO;
button.adjustsImageWhenHighlighted = NO;
UILabel *label = [ [ UILabel alloc ] initWithFrame:CGRectMake(15.0, 5.0, 45, 22.0) ];
label.alpha = 1.0;
label.backgroundColor = [UIColor clearColor];
label.text = title;
label.textAlignment = UITextAlignmentRight;
[customView addSubview: button ];
[customView addSubview:label ];
[customView sendSubviewToBack:button];
return customView;
}
Любой ключ, как решить эту проблему?