I have an UITableViewController
and I customize its UITableViewCell
s. Each UITableViewCell
contains two UIImageViews
and two UILabel
s. Although when I get into the UITableView
the memory usage raises to 100 MB and i do not know the reason. Here is the code for the cellForRowAtIndexPath
method that handles the cell customization. Can anyone help me with this issue?
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *simpleTableIdentifier = @"Cell";
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:simpleTableIdentifier];
}
UILabel *mnhmeioLabel = (UILabel *)[cell viewWithTag:102];
mnhmeioLabel.frame = CGRectMake(mnhmeioLabel.frame.origin.x,
mnhmeioLabel.frame.origin.y,
191,
21);
Group *tmpGroup = [mnhmeiaTotal objectAtIndex:indexPath.row];
NSLog(@"%@ ",tmpGroup.title);
NSLog(@"%f %f", mnhmeioLabel.bounds.size.width,
mnhmeioLabel.bounds.size.height);
mnhmeioLabel.text = tmpGroup.title;
mnhmeioLabel.font = [UIFont fontWithName:@"Open Sans" size:10];
mnhmeioLabel.numberOfLines=0;
mnhmeioLabel.lineBreakMode=NSLineBreakByWordWrapping;
[mnhmeioLabel sizeToFit];
if( tmpGroup.imagesOfArticle.count > 0 ){
UIImageView *mnhmeioImageView = (UIImageView *)[cell viewWithTag:103];
mnhmeioImageView.image = [tmpGroup.imagesOfArticle objectAtIndex:0];
} else {
UIImageView *mnhmeioImageView = (UIImageView *)[cell viewWithTag:103];
mnhmeioImageView.image = [UIImage imageNamed:@""];
}
UIImageView *markerImageView=(UIImageView *)[cell viewWithTag:100];
markerImageView.image=[self selectMarker:tmpGroup];
UILabel *mnhmeioDescription = (UILabel *)[cell viewWithTag:101];
mnhmeioDescription.text=tmpGroup.constructedContent;
mnhmeioDescription.font = [UIFont fontWithName:@"Open Sans" size:6];
}
Probably, the images are big.
Or, perhaps you are not reusing the cells properly, if you are using iOS7 and Storyboards, please follow this tutorial (Prototype cells and Using subclass for a cell sections): http://www.raywenderlich.com/50308/storyboards-tutorial-in-ios-7-part-1
Thank you all for your help. I had to decrease the size of each image as much as i could. This fixed my problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.