ios - programmatically added UILabel to the UITableView not loading properly -


i want dynamically add uilabel uitableviewcell. in cellforrowatindex event did this.

static nsstring *simpletableidentifier = @"simpletablecell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:simpletableidentifier]; uilabel *lbl; [[cell viewwithtag:100] removefromsuperview];  if (cell == nil) {     cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:simpletableidentifier];    }  lbl=[[uilabel alloc] initwithframe:cell.imageview.frame]; [lbl settext:[nsstring stringwithformat:@"%lu",[[[mutarraypendingrequests objectatindex:indexpath.row] objectforkey:@"requestitems"] count]]]; [lbl settag:100]; [lbl settextalignment:nstextalignmentcenter]; [cell.contentview addsubview:lbl]; 

but problem when table loads text has not set uilabel. once scrolled loads top 3 cells , bottom 3 cells. middle cells label not loading. reason this? how can add uilabelas custom view uitableviewcell? please me. thanks

the frame size setting label i.e. cell.imageview.frame invalid.

set proper frame value , check work.

lbl=[[uilabel alloc] initwithframe:cgrectmake(0, 0, 100, 20)]; 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -