gpt4 book ai didi

objective-c - 滑动 Custome UITableViewCell/Custom UITableViewController 时内存泄漏

转载 作者:行者123 更新时间:2023-11-29 13:34:57 29 4
gpt4 key购买 nike

我在我的 iPhone 4S 上运行我的应用程序,我正在使用自定义表格 View Controller 和自定义表格 View 单元格,当我将表格 View 向上滑动到空白区域并同样向下滑动到空白区域时,出现内存泄漏,请参见附图 enter image description here

我似乎无法查明问题出在哪里,或者即使是导致问题的细胞。

我有一个 SeasonTableViewController,

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{


static NSString *CellIdentifier = @"SeasonTableViewCell";

//SeasonTableViewCell *cell = (SeasonTableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
SeasonTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSLog(@"%@",[tableView dequeueReusableCellWithIdentifier:CellIdentifier]);
if(cell==nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"STableView" owner:self options:nil];

//cell = [[[SeasonTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]autorelease];

cell = (SeasonTableViewCell*)[nib objectAtIndex:0];
}

Season *season = [seasonTableArray objectAtIndex:[indexPath row]];

cell.label1.text = [NSString stringWithFormat:@"%@",[season season_title]];

cell.contentView.backgroundColor = [UIColor redColor];


return cell;
}

这是 NSLog 上 NSLog@"%@",[tableview dequeResuableCellWithIdentifier:.....] 的输出;

2012-05-31 11:26:10.799 myTVApp[1462:707] (null)
2012-05-31 11:26:10.804 myTVApp[1462:707] (null)
2012-05-31 11:26:10.809 myTVApp[1462:707] (null)
2012-05-31 11:26:10.813 myTVApp[1462:707] (null)
2012-05-31 11:26:10.817 myTVApp[1462:707] (null)
2012-05-31 11:26:11.185 myTVApp[1462:707] <SeasonTableViewCell: 0xfe24da0; baseClass = UITableViewCell; frame = (0 44; 320 44); autoresize = W; layer = <CALayer: 0xfe24860>>
2012-05-31 11:26:11.187 myTVApp[1462:707] <SeasonTableViewCell: 0xfe25730; baseClass = UITableViewCell; frame = (0 132; 320 44); autoresize = W; layer = <CALayer: 0xfe244a0>>
2012-05-31 11:26:11.189 myTVApp[1462:707] (null)
2012-05-31 11:26:11.191 myTVApp[1462:707] (null)
2012-05-31 11:26:11.194 myTVApp[1462:707] (null)

在上面..我在 myTableView 中显示了 5 个自定义的 SeasonTableViewCells,其余的只是正常的白色单元格,里面什么也没有,

下面是SeasonTableViewCell,

#import "SeasonTableViewCell.h"

@implementation SeasonTableViewCell
@synthesize label1;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];

// Configure the view for the selected state
}

-(void)dealloc
{
[super dealloc];
[label1 release];
//[label2 release];
}

感谢您提供任何指示帮助,并在此先感谢您!

最佳答案

这是最新 iOS 中的一个已知错误。参见 this thread on the developer forums (在线程底部附近,一位 Apple 员工解释说)。

关于objective-c - 滑动 Custome UITableViewCell/Custom UITableViewController 时内存泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10831856/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com