ios - Memory Managing structure in tabeview -
i have facing memory issue, working on 1 magazine app, in app want show article list. fetching server data , show content in table view. have programatically create custom cell in cell creating 3 labels , 1 imageview. when run app in simulator showing 60 mb memory. confused how resolve memory.
here sample implemented,
if (cell == nil) { float cellheight =[self managingheight:indexpath.row withsection:indexpath.section]; cell = [[uitableviewcell alloc] initwithframe:cgrectzero]; cell.selectionstyle = uitableviewcellselectionstylenone; cell.contentview.backgroundcolor = [uicolor clearcolor]; uilabel *lbl_maintitle = [[uilabel alloc] initwithframe:cgrectmake(left_space, top_space + category_max_height + (stnd_space*2), maximumlabelsize.width - stnd_space, 20)]; [lbl_maintitle setbackgroundcolor:stat_titlebackgroundclolor]; [lbl_maintitle settextcolor:stat_titletextcolor]; [lbl_maintitle setfont:[uifont fontwithname:stat_titlefontname size:stat_titlefontsize]]; lbl_maintitle.numberoflines=0; lbl_maintitle.linebreakmode=nslinebreakbywordwrapping; [lbl_maintitle settag:2]; lbl_maintitle.autoresizingmask = uiviewautoresizingflexiblewidth & uiviewautoresizingflexibleheight; [cell.contentview addsubview:lbl_maintitle]; } in project enabled arc.
please check , let me know. thanks
you should reuse cell below method.
- (id)initwithstyle:(uitableviewcellstyle)style reuseidentifier:(nsstring *)reuseidentifier; write code in below way:
static nsstring *identifier = @"identifier"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:identifier]; if (cell == nil) { float cellheight =[self managingheight:indexpath.row withsection:indexpath.section]; cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:identifier]; cell.selectionstyle = uitableviewcellselectionstylenone; cell.contentview.backgroundcolor = [uicolor clearcolor]; uilabel *lbl_maintitle = [[uilabel alloc] initwithframe:cgrectmake(left_space, top_space + category_max_height + (stnd_space*2), maximumlabelsize.width - stnd_space, 20)]; [lbl_maintitle setbackgroundcolor:stat_titlebackgroundclolor]; [lbl_maintitle settextcolor:stat_titletextcolor]; [lbl_maintitle setfont:[uifont fontwithname:stat_titlefontname size:stat_titlefontsize]]; lbl_maintitle.numberoflines=0; lbl_maintitle.linebreakmode=nslinebreakbywordwrapping; [lbl_maintitle settag:2]; lbl_maintitle.autoresizingmask = uiviewautoresizingflexiblewidth & uiviewautoresizingflexibleheight; [cell.contentview addsubview:lbl_maintitle]; }
Comments
Post a Comment