IOS 8 table view controller performance issues

After upgrading to iOS 8, my application has serious performance issues when scrolling in a UITableView - this is not at all on iOS 7. It seems to be a little behind or constantly bouncing a bit.

This affects both older (2nd generation) and newer (4th generation Retina) iPads, but not the iPhone, as my iPhone 5 scrolls through TableViews, built in exactly the same way.

It is important . It seems that this only affects the UITableViewControllers presented modally in the form sheet, and not the table views created manually elsewhere in the UIViewController by default. Even the formally presented UIViewController sheet form with a custom table view (as a property, for example) is not affected.

The tools say that about 3% of the processor’s time is spent on the cellForRowAtIndex method, and this method is the most consuming. Of these 3%, 75% goes to the line:

EventTableViewCell *cell = [tableView
                            dequeueReusableCellWithIdentifier:CellIdentifier
                            forIndexPath:indexPath];

cellForRowAtIndex is as follows:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"tablecell";

    EventTableViewCell *cell = [tableView
                                dequeueReusableCellWithIdentifier:CellIdentifier
                                forIndexPath:indexPath];

    NSDictionary *thismsg = [messages objectAtIndex:indexPath.row];

    switch ([[thismsg objectForKey:@"type"] intValue]) {
        case 1:
        cell.eventTitleLabel.textColor = [UIColor greenColor];
            break;
        case 2:
      cell.eventTitleLabel.textColor = [UIColor redColor];
            break;
        case 3:
       cell.eventTitleLabel.textColor = [UIColor colorWithRed:0.0 green:128.0/255.0 blue:1.0 alpha:1];
            break;
        case 4:
           cell.eventTitleLabel.textColor = [UIColor orangeColor];
            break;
        default:
           cell.eventTitleLabel.textColor = [UIColor whiteColor];
            break;

    }
    cell.eventTitleLabel.text = [thismsg objectForKey:@"m"];
    cell.timestampLabel.text = [thismsg objectForKey:@"t"];
    cell.authorNameLabel.text = [thismsg objectForKey:@"a"];

    cell.backgroundColor = [UIColor blackColor]; // this needs to be here, but removing it makes no difference to performance.
    return cell;
}

In my subclass cell, there are only a few shortcuts made with IB, which are the ones to which the text is assigned.

The storyboard settings for the View Viewer and Table View are as follows: enter image description here

EventTableViewCell.h:

, ,

@interface EventTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *eventTitleLabel;
@property (weak, nonatomic) IBOutlet UILabel *timestampLabel;
@property (weak, nonatomic) IBOutlet UILabel *authorNameLabel;

@end

EventTableViewCell.m:

@implementation EventTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code

    }
    return self;
}

- (void)awakeFromNib
{
    // commenting out this method does nothing to performance, only makes it the wrong color
    UIView *bgColorView = [[UIView alloc] init];
    bgColorView.backgroundColor = [UIColor darkGrayColor];
    [self setSelectedBackgroundView:bgColorView];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
}


@end

Debug Navigator (, - ). 15% . 25% - , , iPad 4 . , , , , . 0% - , , , , - . , , , 23 , .

enter image description here

+4
2

EDIT: iOS 10. , , iOS 10 , iOS7 - , . . 10.1 10.2. - , .

. .

, View Controller, .

, :

, VC. VC, - .

cellForRow , .

iPad . , . iOS 8, . , , - 0,7 Table View . , .

, alpha , , , iOS 7.

- Google iOS 8, .

- , , .

+2

:

NIB dequeueReusableCellWithIdentifier:forIndexPath:. , , , . if ( cell == nil ).

, , :

UIView *bgColorView = [[UIView alloc] init];
bgColorView.backgroundColor = [UIColor darkGrayColor];
[cell setSelectedBackgroundView:bgColorView];

, GPU. , , GPU. , .

, NIB, NIB , , , , EventTableViewCell -initWithStyle:.

, , :

// e.g. in viewDidLoad, assuming you have self.tableView; this tells the
// tableview that the class EventTableViewCell is the thing that is used to
// display any data with which you'd supply the reuse
// identifier CellIdentifier
[self.tableView registerClass:[EventTableViewCell class] 
         forCellReuseIdentifier:CellIdentifier];

... elsewhere ...
-(UITableViewCell *)
  tableView:(UITableView *)tableView
  cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    EventTableViewCell *cell = [tableView 
           dequeueReusableCellWithIdentifier:CellIdentifier
           forIndexPath:indexPath];

    // cell now definitely exists and is non-nil if EventTableViewCell
    // is currently returning non-nil objects for 
    // initWithStyle:reuseIdentifier:; there definitely no point calling
    // that again, at least

    NSDictionary *thismsg = [messages objectAtIndex:indexPath.row];
... etc ...

, . , , tableview. , EventTableViewCell - , - ..

+2

All Articles