0

には4〜5つのセクションがありUITableView、各セクションで異なるカスタムを使用したいと思いますUITableViewCell

委任機能の下でのセルの割り当て

-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath 

しかし、テーブルのさまざまなセクションにさまざまなセルを割り当てるにはどうすればよいですか?

4

1 に答える 1

2

インデックス パスを使用して、さまざまなセクションとさまざまなセクションのさまざまな実装を識別することができます。

-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {

    if(indexPath.section == 0) {
         // Have custom implementation for first section
    }
    else if(indexPath.section == 1) {
         // Have custom implementation for second section and similarly others
    }
}
于 2012-06-27T06:41:32.870 に答える