Note that there are some explanatory texts on larger screens.

plurals
  1. POindex 1 beyond bounds [0 .. 0] with custom cell and SWTableViewCell
    primarykey
    data
    text
    <p>I'm trying to add custom cells to a static <code>UITableViewController</code>. I use <a href="https://github.com/CEWendel/SWTableViewCell" rel="nofollow">SWTableViewCell</a> to get the swipable cell and I'm using a custom -xib for the cell layout. </p> <p>I seems to work fine when I only need to use one cell, but when there are more then one I get this: <code>Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]'</code></p> <p>This happens when I use <code>dequeueReusableCellWithIdentifier</code> in the <code>cellForRowAtIndexPath</code> when the second cell should appear (when I begin to scroll). </p> <p>Here is my code: </p> <pre><code> - (void)viewDidLoad { [super viewDidLoad]; self.images = selectedReport.image; imagesArray = [self.images.allObjects mutableCopy]; self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; [self.tableView registerNib:[UINib nibWithNibName:@"PictureCell" bundle:nil] forCellReuseIdentifier:@"PictureCell"]; } - (NSInteger) tableView:(UITableView *) tableView numberOfRowsInSection:(NSInteger) section { if(section == 0){ return 10; }else if(section == 1){ return imagesArray.count; //It is the second section which is dynamic } return 1; } - (UITableViewCell *) tableView:(UITableView *) tableView cellForRowAtIndexPath:(NSIndexPath *) indexPath { static NSString* cellIdentifier = @"PictureCell"; if (indexPath.section == 0 || indexPath.section == 2) { //Takes the rows from the storyboard return [super tableView:tableView cellForRowAtIndexPath:indexPath]; } else { NSLog(@"%i",indexPath.row); NSLog(@"%i",indexPath.section); PictureTableViewCell *cell = (PictureTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath]; //Crash here when indexPath.row == 1 [cell setCellHeight:cell.frame.size.height]; cell.containingTableView = tableView; indexPath.section, indexPath.row]; Image *tempImage = imagesArray[indexPath.row]; cell.image.image = [UIImage imageWithData:tempImage.image]; cell.lblDescription.text = tempImage.image_description; cell.rightUtilityButtons = [self rightButtons]; cell.delegate = self; return cell; } } </code></pre> <p>I have checked that <code>numberOfRowsInSection</code> returns 2 when section == 1.</p> <p>Thank you for any assistance!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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