我为我的应用程序运行了仪器(其中包含 UITableView)并得到了以下结果
每次单元格变得可见时,单元格将调用方法 [UICustomButton SetButtonWithAnswer....]
编辑:添加了更多屏幕截图
问题是我不确定到底是什么导致了泄漏。我已经在代码中释放了所有的分配初始化。为什么还是漏水?
对此的任何建议将不胜感激!
EDIT:
我添加了 UICustom 按钮,如下所示
if (cell == nil)
{
cell = [[[CustomCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:PlaceholderCellIdentifier] autorelease];
//Add like button
UICustomButton *likeButton = [[UICustomButton alloc]init];
likeButton.tag = 7;
//Add comment button
UICustomButton *commentButton = [[UICustomButton alloc]init];
commentButton.tag = 8;
//Add answer too button
UICustomButton *answerButton = [[UICustomButton alloc]init];
answerButton.tag = 9;
[self.contentView addSubview:likeButton];
[self.contentView addSubview:commentButton];
[self.contentView addSubview:answerButton];
[likeButton release];
[commentButton release];
[answerButton release];
}
//Set like button
UICustomButton *thisLikeButton = (UICustomButton *)[self.contentView viewWithTag:7];
[thisLikeButton setButtonWithAnswer:self.answerForCell buttonType:@"like" navcon:self.navcon andFrame:CGRectMake(CELL_TEXT_LEFT_MARGIN, totalCommentLabelHeight + CELL_SPACING*4, 45, CELL_BUTTON_HEIGHT)];
thisLikeButton.imageView.image = [UIImage imageNamed:@"heart.png"];
//Set comment button
UICustomButton *thisCommentButton = (UICustomButton *)[self.contentView viewWithTag:8];
[thisCommentButton setButtonWithAnswer:self.answerForCell buttonType:@"comment" navcon:self.navcon andFrame:CGRectMake(CELL_TEXT_LEFT_MARGIN + 45 + 5, totalCommentLabelHeight + CELL_SPACING*4, 80, CELL_BUTTON_HEIGHT)];
thisCommentButton.imageView.image = [UIImage imageNamed:@"chat.png"];
//Set answer button
UICustomButton *thisAnswerButton = (UICustomButton *)[self.contentView viewWithTag:9];
[thisAnswerButton setButtonWithAnswer:self.answerForCell buttonType:@"join in" navcon:self.navcon andFrame:CGRectMake(1.5*CELL_TEXT_LEFT_MARGIN + 45 + 5 + 80 + 5, totalCommentLabelHeight + CELL_SPACING*4, 60, CELL_BUTTON_HEIGHT)];
thisAnswerButton.imageView.image = [UIImage imageNamed:@"beer-mug_white.png"];
里面的每个分配/初始化setButton:…
需要重新考虑。你做not想要重新创建这些视图只是为了设置值。
if (self.imageView == nil) {
UIImageView tempImageView = alloc/init …
self.imageView = tempImageView;
[tempImageView release];
}
self.imageView.image = self.image;
标签也一样
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)