0
votes

Hi in my app I want to create tableview basen on values dynamically I need to add UItableView cell with different controls like (cell1 with label,label2),(cell2 with label1,textfield2),(cell3 with label1,segment1) etc.I created UItableViewCell in my Xib.But I am not able to load them dynamically .If any one know reply me Thanks

1

1 Answers

1
votes

You have to do it on the cellForRowAtIndexPath method. Something like this.

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

    if (indexPath.row == 0) {
       return cell0;
    } else if (indexPat.row == 1) {
        return cell1;
    } else if (indexPat.row == 2) {
        return cell2;
    } else if (indexPat.row == 3) {
        return cell3;
    }

}

cell0, cell1, cell2, cell3 are cells you have created on interface builder and linked with an IBOutlet.