Это код моего cellForRowAtIndexPath моего UITableView
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *identificadorNormal = @"Normal";
UITableViewCell *cell;
cell = [tableView dequeueReusableCellWithIdentifier:identificadorNormal];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:identificadorNormal] autorelease];
UILabel * myText = [[[UILabel alloc] initWithFrame:CGRectMake(5.0, 54.0, 225, 18)] autorelease];
[myText setTextAlignment:UITextAlignmentLeft];
[myText setBackgroundColor:[UIColor whiteColor ]];
[myText setClipsToBounds:YES];
[myText setFont:[UIFont systemFontOfSize:14.0]];
[myText setTextColor:[UIColor blackColor]];
[myText setAlpha:0.6];
[myText setTag: 1];
[cell addSubview:myText];
UILabel * labelFRE = [[[UILabel alloc] initWithFrame:CGRectMake(235.0, 54.0, 80, 18)] autorelease];
[labelFRE setTextAlignment:UITextAlignmentCenter];
[labelFRE setBackgroundColor:[UIColor greenColor ]];
[labelFRE setClipsToBounds:YES];
[labelFRE setFont:[UIFont boldSystemFontOfSize:14.0]];
[labelFRE setTextColor:[UIColor blackColor]];
[labelFRE setAlpha:0.75];
[labelFRE setTag: 2];
[cell addSubview:labelFRE];
}
cell.imageView.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]
pathForResource:[NSString stringWithFormat: @"table%d", indexPath.row] ofType:@"jpg"]];
NSString * preffix = [NSString stringWithFormat: @"grat%d", indexPath.row];
UILabel *myText2 = (UILabel*)[cell viewWithTag:1];
[myText2 setText:NSLocalizedString(preffix, @"")];
UILabel *labelFRE2 = (UILabel*)[cell viewWithTag:2];
[labelFRE2 setText:NSLocalizedString(@"frKey", @"")];
return cell;
}
Это чертовски протекает. Каждый раз, когда я прокручиваю таблицу, в список инструментов добавляются новые утечки.
Ребята, вы можете определить, почему?
спасибо за любую помощь.
EDIT
После первого раунда комментариев я изменил предыдущий код на этот
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *identificadorNormal = @"Normal";
UITableViewCell *cell;
cell = [tableView dequeueReusableCellWithIdentifier: identificadorNormal];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:identificadorNormal] autorelease];
UILabel * myText = [[UILabel alloc] initWithFrame:CGRectMake(5.0, 54.0, 225, 18)];
[myText setTextAlignment:UITextAlignmentLeft];
[myText setBackgroundColor:[UIColor whiteColor ]];
[myText setClipsToBounds:YES];
[myText setFont:[UIFont systemFontOfSize:14.0]];
[myText setTextColor:[UIColor blackColor]];
[myText setAlpha:0.6];
[myText setTag: 1];
[cell addSubview:myText];
[myText release];
UILabel * labelFRE = [[UILabel alloc] initWithFrame:CGRectMake(235.0, 54.0, 80, 18)];
[labelFRE setTextAlignment:UITextAlignmentCenter];
[labelFRE setBackgroundColor:[UIColor greenColor ]];
[labelFRE setClipsToBounds:YES];
[labelFRE setFont:[UIFont boldSystemFontOfSize:14.0]];
[labelFRE setTextColor:[UIColor blackColor]];
[labelFRE setAlpha:0.75];
[labelFRE setTag: 2];
[cell addSubview:labelFRE];
[labelFRE release];
}
cell.imageView.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]
pathForResource:[NSString stringWithFormat: @"table%d", indexPath.row] ofType:@"jpg"]];
NSString * preffix = [NSString stringWithFormat: @"grat%d", indexPath.row];
UILabel *myText2 = (UILabel*)[cell viewWithTag:1];
[myText2 setText:NSLocalizedString(preffix, @"")];
UILabel *labelFRE2 = (UILabel*)[cell viewWithTag:2];
[labelFRE2 setText:NSLocalizedString(@"frKey", @"")];
return cell;
}
утечки продолжаются. Без изменений.