How to add a view on cell.contentview of uitableview iphone sdk
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 anot开发者_Python百科her 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.
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
精彩评论