TableView titleForHeaderInSection - PullRequest
       2

TableView titleForHeaderInSection

1 голос
/ 23 февраля 2012

Мое приложение показывает это в симуляторе 4.3.1 и в симуляторе 5.0.

4.3.1 simulator5.0 simulator

Это код:

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
   return @""; 
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return [[Singleton sharedInstance] getTitleSectionView:segmentedControl.selectedSegmentIndex inDay:section];
}
-(UIView *)getTitleSectionView:(int)week inDay:(int)day;
{
UILabel *lab=[[[UILabel alloc]init]autorelease];
lab.frame=CGRectMake(5, 0,320,20);
lab.text=[[Singleton sharedInstance] getTitleSection:week inDay:day];
lab.backgroundColor=[UIColor clearColor];
lab.textColor=[UIColor whiteColor];
lab.font = [UIFont fontWithName:@"Arial" size:14];

UIImageView * imv = [[[UIImageView alloc]initWithFrame:CGRectMake(0,0, 320, 20)]autorelease];
imv.image=[UIImage imageNamed:@"section-header-bg.png"];

UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 20)]autorelease];
[view addSubview:imv];
[view addSubview:lab];

    Week *currentWeek = nil;
    if(week)    
        currentWeek = nechetNedel;
    else        
        currentWeek = chetNedel;

    NSMutableArray *dayArray = [currentWeek.days objectAtIndex:day];
    if([dayArray count] >0)
        return view;
    return nil;
}

В чем может быть проблема, почему линии симуляций появляются в симуляторе 5.0? Я пытался удалить метод - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section, но это не помогло. Я удаляю этот метод (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section и строки исчезают

1 Ответ

5 голосов
/ 23 февраля 2012

Вы должны вернуть ноль для пустых разделов

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;

и

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;

должен вернуть 0

Тогда это будет работать. Это проблема iOS 5.x (или функция)

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...