ios - UITableViewCells Images causing memory growth -
i creating set of profiles individualized images (user selectable) each profile. profiles shown using uitableviewcontroller created storyboard. code works fine, when transition modally viewcontroller using storyboard, memory each of images remain. if transition uitableviewcontroller, memory doubles, , images seems reloaded memory. using arc, , images stored in standarduserdefault. below relevant code:
- (void)viewdidload { [super viewdidload]; profiles = [[[nsuserdefaults standarduserdefaults] dictionaryforkey:@"profilename"] allkeys]; nsmutabledictionary *temp = [[nsmutabledictionary alloc] init]; for(nsstring *profname in profiles) { nsdata* imagedata = [[nsuserdefaults standarduserdefaults] objectforkey:[nsstring stringwithformat:@"%@-image", profname]]; [temp setobject:[uiimage imagewithdata:imagedata] forkey:profname]; } images = [nsdictionary dictionarywithdictionary:temp]; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"profiles"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:cellidentifier]; } // configure cell... nsstring *profname = [profiles objectatindex:indexpath.row]; [cell.textlabel settext:profname]; cell.imageview.image = [images objectforkey:profname]; return cell; }
if replace line sets images each cell code such below:
cell.imageview.image = [uiimage imagenamed:@"someimage.png"];
the memory frees fine. not doing else free memory or setting nil in other part of code. can me identify way free memory when transition uitableviewcontroller? i'm open suggestions of other ways save image user selects profile (from uiimagepickercontroller).
Comments
Post a Comment