2012-02-23 9 views
1

マイアプリ          5.0シミュレータで                         この4.3.1シミュレータでこれを示しています。テーブルビューtitleForHeaderInSection

4.3.1 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を削除し、行は

+2

のiOS 5.xの問題(または機能)である 'numberOfSectionsInTableViewたちを表示:'。 –

+0

- (NSInteger)numberOfSectionsInTableView:(のUITableView *)のtableView { リターン7。 } – Pavel

+1

、現在のiOS 5 SIMで茶色がかった灰色のヘッダを数えます。あなたはそれを得る? –

答えて

5

消え0

を返す必要がありますが、それは動作します空のセクション

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

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

にnilを返す必要があります。それは

+0

になります理解していない - (UIViewの*)のtableView:ここで私はnilを返しますそしてタイトルの画像が表示されますが、灰色の線が表示されない、 - (CGFloat)のtableView:私は0を返し、ここでなら、私は、このメソッドの画像を見ていない - のtableView(UIViewの*):IOS 4.3で – Pavel

+0

それの仕事が、なぜにそれ以前に働いていたが、5.0では動作していなかったので理解できない – Pavel

+1

理解できない場合は、ドキュメントを読んでください。 iOSの5.0のリリースノートは非常に明確にこの点を呼び出す:「[のiOS 5では]のtableViewからnilを返す:viewForHeaderInSection:もはやヘッダを隠すのに十分ではない方法(またはそのフッタに相当)あなたがオーバーライドする必要がありますのtableViewを:heightForHeaderInSection:ヘッダーを隠すために0.0を返します。 " – matt

関連する問題