Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Sergio10

macrumors regular
Original poster
Oct 3, 2007
137
0
Hi,

I have XIB bundle with UITableViewCell, UITable and UIView called "MyBundle".

And I'd like to display cell loaded from XIB many times(reuse it).

So I've created in UIViewController outlet of the cell, set Identifier and tried next code:
PHP:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
[myCell prepareForReuse];

	return myCell;
}
As result it shows only one cell. But it should be shown 10 items.

I also tried next:
PHP:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"CustomCellId"];

    if (cell == nil) {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"MyBundle" owner:self options:nil];
        cell = (UITableViewCell *)[nib objectAtIndex:0];
    }

    return cell;
}
How to solve the problem?

Thank you.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.