2010-12-13 3 views
0

私の質問のように、私はちょうど彼/彼女のtableviewとtableviewcellの背景を使用するアプリケーションを作った人に尋ねたい。私はそれらの背景に問題があります。ここに私のアプリのPICは、私がtableviewcellに背景用テーブルビューとwhitecolorに背景にgraycolorを使用し、問題 alt texttableviewとtableviewcellのバックグラウンドを使ってアプリケーションを作った人は誰ですか?

であり、私は、テキストがwhitecolorバックグラウンドを持っているcontaintすべてのセルを作りたいが、私はそれを行うことはできません。 ここに私のコードは

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{ 
UIView* backgroundView = [ [ [ UIView alloc ] initWithFrame:CGRectZero ] autorelease ]; 

//--new color code-- 
backgroundView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"celltable_root.png"]]; 

cell.backgroundView = backgroundView; 
for (UIView* view in cell.contentView.subviews) 
{ 
    if(_segmentedControl.selectedSegmentIndex == 0){ 
     FileModel *filemodels = [_filemodels objectAtIndex:indexPath.row]; 
     if([filemodels.fileExpanse compare:@"display"]==0){ 

      backgroundView.backgroundColor = [UIColor whiteColor]; 


     }else{ 
      backgroundView.backgroundColor = [UIColor whiteColor]; 

     } 
    } 

    view.backgroundColor = [ UIColor clearColor]; //set cell background 

} 

    [[self tableView] setBackgroundColor:[UIColor grayColor]]; 

}

私のコードで何かが間違っているのです?

+0

あなたは、 "私はすべてのセルに白黒の背景があるようにしたい"と書いています。テーブルに表示したいお願いしてください。その後、私は助けるかもしれません。 – Developer

+0

hhmmm ...多分そのテーブルの10行、テキストは配列 –

+0

からいっぱいです。そして、urは "noOfRowsInSection"で書かなければなりません。return [yourArray count];私はあなたの質問を明確に得ていないので、私はそれを更新するurコードのリンクを提供してください。もう一つのこと:それはどういう意味ですか? if([filemodels.fileExpanse compare:@ "display"] == 0){ backgroundView.backgroundColor = [UIColor whiteColor]; }他{ backgroundView.backgroundColor = [UIColor whiteColor]。 }どちらの場合も の出力は同じです。 – Developer

答えて

0

チェックアウトthis article on cocoa with love。私はそれがあなたが求めていることをカバーしていると思います。

+0

thxで書く、私はカスタマイズすることができるコードを持っている、と私は本当にthx .. –

0

私はすでにデレクが私に与えたのリンクを読んで、私は私が使用できるコードを発見しました。私は、セルの背景とテーブルの背景に画像を使用することに決めました。 このこの質問

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{ 

    if(_segmentedControl.selectedSegmentIndex == 0){ 
     FileModel *filemodels = [_filemodels objectAtIndex:indexPath.row]; 
     if([filemodels.fileExpanse compare:@"display"]==0){ 

      ((UIImageView *)cell.backgroundView).image = [UIImage imageNamed:@"whiteColor.png"]; 

     }else{ 
      ((UIImageView *)cell.backgroundView).image = [UIImage imageNamed:@"whiteColor.png"]; 

     } 
    } 

    [[self tableView] setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"grayColor.png"]]]; //tableview background using image 

}

に答えるために私のコードであり、私はviewDidLoadメソッドに

[[self tableView] setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"grayColor.png"]]]; //tableview background using image 

を追加し、そして最後に...この問題が解決されます。 Thx everyone ... (n_n)

関連する問題