Note that there are some explanatory texts on larger screens.

plurals
  1. POTable View load more cell?
    text
    copied!<p>trying to make a cell which loads more, but i cant get it to appear after the other cells, sorry for being vague but ill show you my code...</p> <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [rows count] + 1; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *postCellId = @"postCell"; UITableViewCell *cell = nil; cell = [self.tableView dequeueReusableCellWithIdentifier:postCellId]; cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:postCellId]; NSUInteger row = [indexPath row]; NSUInteger count = [rows count]; if (row == count) { loadMore = [[UILabel alloc] initWithFrame:CGRectMake(0, 30, 320, 25)]; loadMore.backgroundColor = [UIColor colorWithRed:255.0 / 255.0 green:255.0 / 255.0 blue:255.0 / 255.0 alpha:1.0]; loadMore.font = [UIFont fontWithName:@"AvenirNext-Bold" size:18.0]; loadMore.textColor = [UIColor colorWithRed:60.0 / 255.0 green:58.0 / 255.0 blue:55.0 / 255.0 alpha:1.0]; loadMore.text = @"Load More..."; loadMore.textAlignment = UITextAlignmentCenter; [cell.contentView addSubview:loadMore]; displaying = [[UILabel alloc] initWithFrame:CGRectMake(0, 50, 320, 25)]; displaying.backgroundColor = [UIColor colorWithRed:255.0 / 255.0 green:255.0 / 255.0 blue:255.0 / 255.0 alpha:1.0]; displaying.font = [UIFont fontWithName:@"AvenirNext-Bold" size:12.0]; displaying.textColor = [UIColor colorWithRed: 115.0 / 255.0 green: 113.0/ 255.0 blue:112.0 / 255.0 alpha:1.0]; displaying.text = [NSString stringWithFormat:@"Displaying %i Results", rows.count]; displaying.textAlignment = UITextAlignmentCenter; [cell.contentView addSubview:displaying]; } else { dict = rows[indexPath.row]; thumbimgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 80, 80)]; businessLabel = [[UILabel alloc] initWithFrame:CGRectMake(103, 10, 207, 25)]; locationLabel = [[UILabel alloc] initWithFrame:CGRectMake(103, 35, 207, 35)]; locimgView = [[UIImageView alloc] initWithFrame:CGRectMake(220, 75, 20, 15)]; distanceLabel = [[UILabel alloc] initWithFrame:CGRectMake(240, 75, 60, 15)]; businessLabel.backgroundColor = [UIColor colorWithRed:255.0 / 255.0 green:255.0 / 255.0 blue:255.0 / 255.0 alpha:1.0]; businessLabel.font = [UIFont fontWithName:@"AvenirNext-Bold" size:18.0]; businessLabel.textColor = [UIColor colorWithRed:60.0 / 255.0 green:58.0 / 255.0 blue:55.0 / 255.0 alpha:1.0]; businessLabel.text = dict[@"business"]; [cell.contentView addSubview:businessLabel]; locationLabel.backgroundColor = [UIColor colorWithRed:255.0 / 255.0 green:255.0 / 255.0 blue:255.0 / 255.0 alpha:1.0]; locationLabel.font = [UIFont fontWithName:@"AvenirNext-Regular" size:14.0]; locationLabel.text = dict[@"location"]; locationLabel.textColor = [UIColor colorWithRed: 115.0 / 255.0 green: 113.0/ 255.0 blue:112.0 / 255.0 alpha:1.0]; locationLabel.numberOfLines = 2; locationLabel.lineBreakMode = UILineBreakModeTailTruncation; [cell.contentView addSubview:locationLabel]; listingLoc = [[CLLocation alloc] initWithLatitude:[dict[@"lat"] doubleValue] longitude:[dict[@"lon"] doubleValue]]; AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; float kilometers = [appDelegate.currentLoc distanceFromLocation:listingLoc] / 1000; int milesint = kilometers * 0.621371192; NSString *milesOut = [NSString stringWithFormat:@"%i miles", milesint]; distanceLabel.backgroundColor = [UIColor colorWithRed:255.0 / 255.0 green:255.0 / 255.0 blue:255.0 / 255.0 alpha:1.0]; distanceLabel.font = [UIFont fontWithName:@"AvenirNext-Regular" size:12.0]; distanceLabel.textColor = [UIColor colorWithRed:128.0 / 255.0 green:128.0 / 255.0 blue:128.0 / 255.0 alpha:1.0]; distanceLabel.text = milesOut; [cell.contentView addSubview:distanceLabel]; NSArray *splitImages = [dict[@"image1"] componentsSeparatedByString:@", "]; icon = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[splitImages objectAtIndex:0]]]]; [thumbimgView setContentMode:UIViewContentModeScaleAspectFill]; [thumbimgView setClipsToBounds:YES]; thumbimgView.image = icon; [cell.contentView addSubview:thumbimgView]; locimgView.image = [UIImage imageNamed:@"location-icon.png"]; [cell.contentView addSubview:locimgView]; cell.textLabel.text = dict[@"business"]; cell.textLabel.hidden = YES; } return cell; } </code></pre> <p>All it does is return the data from the array, and no cell is added after for the load more.. Many thanks.</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