title: Unexpected delay when presenting UITableViewController
body: <p>I have a custom <code>UITableViewCell</code> in a <code>UITableViewController</code>, but when the Controller tries to dequeue the custom cell, it will take a long time (like 2000ms).</p>
  
  <p>This line of code causes the problem</p>
  
  <pre><code>KidsListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"kidsReuseIdentifier" forIndexPath:indexPath];
  </code></pre>
  
  <p>The <code>KidsListTableViewCell</code> is a custom cell, which includes couple of <code>UIButton</code>s, some <code>UILabel</code>s to show the information. And two delegate methods. It shouldn't be that slow to render that view. By the way, all of the information in the custom cell is basically static. </p>
  
  <p>The is the full code of the UITableViewController. I put the custom view and regular view in different sections and I don't think this causes the problem.</p>
  
  <pre><code>#import "KidDetailTableViewController.h"
  #import "KidDetailHeaderTableViewCell.h"
  #import &lt;AssetsLibrary/AssetsLibrary.h&gt;
  #import "Helper.h"
  
  @interface KidDetailTableViewController () &lt;KidDetailHeaderCellDelegate&gt;
  
  @end
  
  @implementation KidDetailTableViewController
  {
      KidDetailHeaderTableViewCell *headerCell;
  }
  
  - (void)viewDidLoad {
      [super viewDidLoad];
  
      [self.tableView registerNib:[UINib nibWithNibName:@"KidDetailHeader" bundle:nil] forCellReuseIdentifier:@"kidDetail"];
  
      [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"detailCell"];
  
  
      self.tableView.showsVerticalScrollIndicator = NO;
  
  }
  
  
  - (void)viewWillAppear:(BOOL)animated {
      [super viewWillAppear:animated];
  
  }
  
  - (void)didReceiveMemoryWarning {
      [super didReceiveMemoryWarning];
      // Dispose of any resources that can be recreated.
  }
  
  #pragma mark - Table view data source
  
  - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
      // Return the number of sections.
      return 2;
  }
  
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  
      switch (section) {
          case 0:
              return 1;
              break;
  
          default:
              return 10;
              break;
      }
  }
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  
      if (indexPath.section == 0) {
          if (!headerCell) {
  
  
              headerCell = [tableView dequeueReusableCellWithIdentifier:@"kidDetail"];
  
              headerCell.delegate = self;
  
  
              // Keep the background color for the cell when select.
              headerCell.selectionStyle = UITableViewCellSelectionStyleNone;
  
              headerCell.nicknameLabel.text = _kidNeedsToShow.nickname;
  
              NSString *kidFullName = [NSString stringWithFormat:@"%@ %@ %@", _kidNeedsToShow.firstName, _kidNeedsToShow.midName, _kidNeedsToShow.lastName];
  
              kidFullName ? (headerCell.fullNameLabel.text = @"") : (headerCell.fullNameLabel.text = kidFullName);
  
  
              // Set thumb image or use default
              // if there isn't image, use default.
              ALAssetsLibrary *library = [ALAssetsLibrary new];
              [library assetForURL:_kidNeedsToShow.photoURL resultBlock:^(ALAsset *asset) {
                  [headerCell.avatarImage setImage:[UIImage imageWithCGImage:[[asset defaultRepresentation] fullResolutionImage]]];
              } failureBlock:nil];
              return headerCell;
          }
          else return headerCell;
      }
  
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"detailCell" forIndexPath:indexPath];
      return cell;
  }
  
  - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
      if (indexPath.section == 0) {
          return 290;
      }
      else return 60;
  }
  
  - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
      if (indexPath.section == 0) {
          return 290;
      }
      else return 60;
  }
  
  - (void)didClickLeftButton:(UIButton *)leftButton {
      [self dismissViewControllerAnimated:YES completion:nil];
  }
  
  @end
  </code></pre>
  
  <p>I tried to put dequeueReusableCellWithIdentifier into a different thread, apparently it wouldn't work.</p>
  
  <p>UPDATE: KidDetailHeaderTableViewCell.m</p>
  
  <pre><code>- (void)awakeFromNib {
      // Initialization code
      [_avatarImage.layer setCornerRadius:_avatarImage.frame.size.width / 2];
      [_avatarImage.layer setBorderColor:[UIColor whiteColor].CGColor];
      [_avatarImage.layer setBorderWidth:1.0];
      [_avatarImage setClipsToBounds:YES];
  
  }
  
  - (IBAction)leftButtonClicked:(UIButton *)sender {
      if (self.delegate &amp;&amp; [self.delegate respondsToSelector:@selector(didClickLeftButton:)]) {
          [self.delegate didClickLeftButton:sender];
      }
  }
  - (IBAction)rightButtonClicked:(UIButton *)sender {
      if (self.delegate &amp;&amp; [self.delegate respondsToSelector:@selector(didClickRightButton:)]) {
          [self.delegate didClickRightButton:sender];
      }
  }
  </code></pre>
  
  <p>KidDetailHeaderTableViewCell.h</p>
  
  <pre><code>@protocol KidDetailHeaderCellDelegate &lt;NSObject&gt;
  
  @optional
  - (void)didClickLeftButton:(UIButton *)leftButton;
  - (void)didClickRightButton:(UIButton *)rightButton;
  
  @end
  
  @interface KidDetailHeaderTableViewCell : UITableViewCell
  
  @property (weak) id&lt;KidDetailHeaderCellDelegate&gt; delegate;
  
  @property (weak, nonatomic) IBOutlet UILabel *fullNameLabel;
  @property (weak, nonatomic) IBOutlet UIImageView *avatarImage;
  @property (weak, nonatomic) IBOutlet UILabel *nicknameLabel;
  
  @property (weak, nonatomic) IBOutlet UILabel *ageText;
  @property (weak, nonatomic) IBOutlet UILabel *ageLabel;
  
  @property (weak, nonatomic) IBOutlet UILabel *momentsStatistics;
  @property (weak, nonatomic) IBOutlet UILabel *momentsLabel;
  
  @property (weak, nonatomic) IBOutlet UIButton *rightButton;
  @property (weak, nonatomic) IBOutlet UIButton *leftButton;
  
  @end
  </code></pre>
  
  <p>UPDATE 2:
  screenshot of instrument 
  <img src="https://i.stack.imgur.com/4pwpp.png" alt="screenshot of instrument"></p>
  
  <p>The code for set the height of the cell. I have two sections, the first section actually is only used for header, the height is 290.</p>
  
  <pre><code>- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
      if (indexPath.section == 0) {
          return 290;
      }
      else return 60;
  }
  </code></pre>