Когда я просматриваю UITableView, память продолжает увеличиваться, и я получаю такие результаты, когда запускаю «Allocations».VM: UITableViewLabel ест память iOS
Я вижу их, что VM: UITableViewLabel память продолжает расти и настойчив, Является ли их каким-либо образом я мог бы удалить это постоянное увеличение памяти
-(UITableViewCell*) tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
NSString *text = @"";
BOOL defaultStyle = YES;
static NSString *CellIdentifier = @"Cell";
UITableViewCell *defaultCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (defaultCell == nil) {
defaultCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
else{
NSLog(@"reusing the cell");
}
defaultCell.textLabel.textAlignment = NSTextAlignmentLeft;
defaultCell.userInteractionEnabled = YES;
defaultCell.textLabel.font = [UIFont systemFontOfSize:26.0f];
UIImageView *iv = defaultCell.imageView;
int totalSections = [self numberOfSectionsInTableView:tableView];
NSInteger computedSection = indexPath.section;
if (defaultStyle)
{
defaultCell.selectionStyle = UITableViewCellSelectionStyleBlue;
defaultCell.backgroundColor = [UIColor whiteColor];
defaultCell.textLabel.textColor = [UIColor blackColor];
}
else if (computedSection == 0)
{
const int totalRows = [self tableView:self.tableView numberOfRowsInSection:indexPath.section];
if (indexPath.row == 0) {
text = @"Style1";
defaultStyle = NO;
if (self.style1 == nil)
{
defaultCell.selectionStyle = UITableViewCellSelectionStyleNone;
defaultCell.textLabel.textColor = [UIColor grayColor];
}
else
{
defaultCell.selectionStyle = UITableViewCellSelectionStyleBlue;
defaultCell.textLabel.textColor = [UIColor blackColor];
}
iv.image = [UIImage imageNamed: @"Style1.png"];
}
if(indexPath.row == totalRows - 2){
// Categories
text = @"Style2";
iv.image = [UIImage imageNamed: @"Style2.png"];
defaultStyle = NO;
if (self.style2 == nil) {
defaultCell.selectionStyle = UITableViewCellSelectionStyleNone;
defaultCell.textLabel.textColor = [UIColor grayColor];
} else {
defaultCell.selectionStyle = UITableViewCellSelectionStyleBlue;
defaultCell.textLabel.textColor = [UIColor blackColor];
}
}
else if (indexPath.row == totalRows - 1){
// Search
text = @"Style3";
iv.image = [UIImage imageNamed: @"Style3.png"];
}
}
else if (computedSection == 1)
{
MyCustomTableViewCell *cell = [mTableView dequeueReusableCellWithIdentifier:kCustomTableCellIdentifier];
if (cell == nil) {
cell = [CustomTableViewCell loadFromNibNamed:@"CustomTableViewCell"];
}
cell.titleLabel = @"custom cell";
cell.openImage =[UIImage imageNamed: @"custom.png"]
return cell;
}
else if (indexPath.section == totalSections - 1)
{
if (indexPath.row == 0)
{
text = @"Account";
defaultStyle = NO;
if (self.hasAccount == nil)
{
defaultCell.selectionStyle = UITableViewCellSelectionStyleNone;
defaultCell.textLabel.textColor = [UIColor grayColor];
}
else
{
defaultCell.selectionStyle = UITableViewCellSelectionStyleBlue;
defaultCell.textLabel.textColor = [UIColor whiteColor];
}
iv.image = [UIImage imageNamed: @"Account.png"];
}
}
defaultCell.textLabel.text = text;
return defaultCell;
}
добавил, что метод – hariszaman
Не могли бы вы также отобразить заголовок класса ProgrammeTableViewCell и реализацию его метода 'dealloc'? – dasblinkenlight
Что такое 'loadFromNibNamed:' метод, который вы используете для загрузки 'ProgrammeTableViewCell'?Если это просто обычная оболочка для 'loadNibNamed: owner: options:', она, скорее всего, написана для среды ARC, в то время как вы используете не-ARC, так что вы можете легко запутаться там с автореализацией. Также есть 'registerNib: forCellReuseIdentifier:' и 'dequeueReusableCellWithIdentifier: forIndexPath:', которые автоматически создают ячейку из NIB, если необходимо, и снимают бремя 'if (cell == nil)' проверок. И эй, почему не-ARC вообще? –