Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating Custom Cell takes the iphone app into an infinite loop
    text
    copied!<p>I have created a very simple application where I am trying to insert a custom cell in a table view. However, whenever I return an instance of the Custom Cell, one nothing is displayed on the screen and second, the application enters some kind of weird infinite loop. Any help would be much appreciated. I have attached my code in this question.</p> <pre><code>-- view controller which is returning custom cells --- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { // Try to recover a cell from the table view with the given identifier, this is for performance CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:@"CustomCell"]; // If no cell is available, create a new one using the given identifier if (cell == nil) { NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"sample_1ViewController" owner:self options:nil]; for (id currentObject in topLevelObjects) { if ([currentObject isKindOfClass:[CustomCell class]]) { cell = currentObject; break; } } } // Fill the cell cell.lbl.text = @"test"; return cell; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 4; } --- custom cell class --- @interface CustomCell : UITableViewCell { IBOutlet UILabel * lbl; } @property (nonatomic, retain) IBOutlet UILabel * lbl; @end @implementation CustomCell @synthesize lbl; @end ---- </code></pre> <p>The custom cell is a UITableCellView resource in the sample_1ViewController.xib file. It contains a UILabel. The identifier for the CustomCell is CustomCell as well.</p> <p>Please see if you could locate something which might be wrong or tell me of something which I am possibly missing out.</p> <p>Regards Nitin</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload