How to add view to cell.contentview uitableview iphone sdk
In my application, I create a .xib of a class and load its .xib into uitableview cells of another class. I want to add this .xib to cell.contentView, not to cell. How can I do it?
- (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 other class where I have two labels and two buttons from which I created a .xib and load it into the tableview cell as above. tCell is an object of the testTableCell class.
This is really relevant. Can anyone please help? Thanks in advance.
+2
a source to share
1 answer
Well, if you're asking about how to add your custom cells to your UITableView rather than using the default UITableViewCell, then it's not very difficult. Just follow all the steps outlined in the following tutorial:
Creating a custom UITableViewCell with the Interface Builder
+1
a source to share