には4〜5つのセクションがありUITableView
、各セクションで異なるカスタムを使用したいと思いますUITableViewCell
。
委任機能の下でのセルの割り当て
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
しかし、テーブルのさまざまなセクションにさまざまなセルを割り当てるにはどうすればよいですか?
には4〜5つのセクションがありUITableView
、各セクションで異なるカスタムを使用したいと思いますUITableViewCell
。
委任機能の下でのセルの割り当て
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
しかし、テーブルのさまざまなセクションにさまざまなセルを割り当てるにはどうすればよいですか?
インデックス パスを使用して、さまざまなセクションとさまざまなセクションのさまざまな実装を識別することができます。
-(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
}
}