2012-06-27 39 views
0

我在UITableView中有4到5个部分,我希望使用不同的自定义UITableViewCell对UITableView使用多个自定义TableViewCell

分配下委托功能

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

细胞但我怎么分配不同的充电池为表的不同部分?

回答

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 
    } 
}