views:

308

answers:

1

Hi all, In my application I'm creating a .xib of a class and loading that .xib on cells of uitableview of another class. I want to add this .xib to cell.contentView and not cell. How shall I do that?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString* cellIdentifier = @"testTableCell";

testTableCell * cell = (testTableCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
    [[NSBundle mainBundle] loadNibNamed:@"testTableCell" owner:self options:nil];
    cell = tCell;
}

return cell;
}

testTableCell is my another class in which I have two labels and two buttons, of which I have created a .xib and loading it to tableview's cell as above. tCell is an object of class testTableCell.

This' really urgent. Can anybody please help? Thanks in advance.

A: 

Well, if you are asking about how to add your custom cells into your UITableView, and not use default UITableViewCell, than its not very difficult. Just follow all the steps described in the following tutorial:

Creating Custom UITableViewCell using Interface Builder

Ansari
And do mark it correct, if this helps you :)
Ansari
Ansari, I have done it the same way, but that way my custom cell isn't getting added to cell's contentView but to cell. I want to add it to contentView.
neha
Nope, it's getting added to contentView itself. Thanx for the help Ansari.
neha
Your Welcome :)
Ansari