1

ナビゲーション コントローラーを使用して、rootView に addColorView をプッシュ アンド ポップします。Leaks インストルメントによると、責任のあるフレーム [UITableView _setupTableViewCommon] を使用してビューをプッシュすると、いくつかのオブジェクトがリークします (3 つの可変配列と 2 つの可変辞書)。

- (void) addButtonPressed {

    NSLog(@"addButtonPressed");
    AddColorViewController *addColorViewController = [[[AddColorViewController alloc] init] autorelease];
    [self.navigationController pushViewController:addColorViewController animated:YES]; // <-- The Leaks tool points right here
}

問題は、実際のリークをどこで探すべきかということです。UIGobblerGestureRecognizer とは一体何ですか?

編集 1: AddColorViewController.m の viewDidLoad メソッド:

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.listOfLabels = [[[NSArray alloc] initWithObjects:@"Name", @"Red", @"Green", @"Blue", nil] autorelease];
    self.navigationItem.title = @"New";

    [self.tableView initWithFrame:self.view.frame style:UITableViewStyleGrouped];
    UIBarButtonItem *homeButton = [[UIBarButtonItem alloc] initWithTitle:@"Home" style:UIBarButtonItemStylePlain target: self action:@selector(homeButtonPressed)];
    UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStylePlain target:self action:@selector(saveButtonPressed)];

    self.navigationItem.leftBarButtonItem = homeButton;
    self.navigationItem.rightBarButtonItem = saveButton;

    [homeButton release];
    [saveButton release];
}

...

- (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        cell.accessoryType = UITableViewCellAccessoryNone;

        UITextField *textField = [[UITextField alloc] init];

        if ([indexPath row] == 0) {
            textField.frame = CGRectMake(220, 10, 170, 30);
            textField.placeholder = @"color";
            textField.keyboardType = UIKeyboardTypeDefault;
        }
        else {
            textField.frame = CGRectMake(220, 10, 80, 30);
            textField.placeholder = @"0..255";
            textField.keyboardType = UIKeyboardTypeNumberPad;
        }

        textField.delegate = self;
        textField.tag = [indexPath row] + 1; 
        textField.adjustsFontSizeToFitWidth = YES;
        textField.textColor = [UIColor blackColor];
        textField.textAlignment = UITextAlignmentLeft;

        [cell addSubview:textField];
        [textField release];
    }

    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.textLabel.text = [self.listOfLabels objectAtIndex:indexPath.row];
    return cell;
}
4

0 に答える 0