ios - Unexpected delay when presenting UITableViewController -


i have custom uitableviewcell in uitableviewcontroller, when controller tries dequeue custom cell, take long time (like 2000ms).

this line of code causes problem

kidslisttableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"kidsreuseidentifier" forindexpath:indexpath]; 

the kidslisttableviewcell custom cell, includes couple of uibuttons, uilabels show information. , 2 delegate methods. shouldn't slow render view. way, of information in custom cell static.

the full code of uitableviewcontroller. put custom view , regular view in different sections , don't think causes problem.

#import "kiddetailtableviewcontroller.h" #import "kiddetailheadertableviewcell.h" #import <assetslibrary/assetslibrary.h> #import "helper.h"  @interface kiddetailtableviewcontroller () <kiddetailheadercelldelegate>  @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 resources can recreated. }  #pragma mark - table view data source  - (nsinteger)numberofsectionsintableview:(uitableview *)tableview {     // return 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 background color 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 

i tried put dequeuereusablecellwithidentifier different thread, apparently wouldn't work.

update: kiddetailheadertableviewcell.m

- (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 && [self.delegate respondstoselector:@selector(didclickleftbutton:)]) {         [self.delegate didclickleftbutton:sender];     } } - (ibaction)rightbuttonclicked:(uibutton *)sender {     if (self.delegate && [self.delegate respondstoselector:@selector(didclickrightbutton:)]) {         [self.delegate didclickrightbutton:sender];     } } 

kiddetailheadertableviewcell.h

@protocol kiddetailheadercelldelegate <nsobject>  @optional - (void)didclickleftbutton:(uibutton *)leftbutton; - (void)didclickrightbutton:(uibutton *)rightbutton;  @end  @interface kiddetailheadertableviewcell : uitableviewcell  @property (weak) id<kiddetailheadercelldelegate> 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 

update 2: screenshot of instrument screenshot of instrument

the code set height of cell. have 2 sections, first section used header, height 290.

- (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath {     if (indexpath.section == 0) {         return 290;     }     else return 60; } 

one of friend pointed out problem caused custom font (yes! used custom font in custom view). still not sure why causes problem (the font named 'hero'), hope else.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -