Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I don't see a problem with the way you're implementing this. I simplified your code (mostly in the "else" clause) and created a dummy array, and everything worked fine. Notice that I am using the new paradigm for creating table view cells that makes it unnecessary to have the "if cell is nil" statement.</p> <pre><code>@implementation TableController { NSArray *rows; } - (void)viewDidLoad { [super viewDidLoad]; [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"postCell"]; rows = @[@"One",@"Two",@"Three",@"Four"]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [rows count] + 1; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"postCell" forIndexPath:indexPath]; NSUInteger row = [indexPath row]; NSUInteger count = [rows count]; if (row == count) { UILabel *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 = NSTextAlignmentCenter; [cell.contentView addSubview:loadMore]; UILabel *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 = NSTextAlignmentCenter; [cell.contentView addSubview:displaying]; } else { cell.textLabel.text = rows[indexPath.row]; } return cell; } </code></pre>
 

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