0

そのため、Core Data で mogenerator を使用しています。最初にテーブルビューをロードしたときに、resultsController は有効な属性を持つ適切なオブジェクトを返します。しかし、テーブルをスクロールすると、リロードされたすべてのセルに、resultsController から返された null 属性を持つオブジェクトが取り込まれます。キャッシングの問題ですか?

- (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];
    }

    // Configure the cell...
    Log *log = [self.resultsController objectAtIndexPath:indexPath];
    cell.textLabel.text = [NSString stringWithFormat:@"%@", log.text];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    return cell;
}
4

1 に答える 1

0

結果コントローラーをviewWillLoadまたはviewDidLoadに入れるべきではないことがわかりました。私はそれを独自のアクセス方法に入れましたが、現在は正常に動作しています。

于 2012-04-05T07:34:01.793 に答える