도구 모음에 NSArray
을 재생성하고 테이블의 내용을 다시로드하려고하는 새로 고침 단추가 있습니다.UITableView가 섹션 및 내용을 다시로드하지 않습니다.
if (boolCondition) {
[self refreshTableDataSet];
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:kTableSectionOfInterest] withRowAnimation:UITableViewRowAnimationFade];
}
또는 : 테이블이 실패 새로 고침
if (boolCondition) {
[self refreshTableDataSet];
[self.tableView reloadData];
}
에 대해 다른 모든 시도를 내가 가지고 있는지하지만
. 때로는 효과가 있고 가끔은 그렇지 않습니다.
NSLog
문은 -tableView:cellForRowAtIndexPath:
에 있는데이 방법을 사용할 때 알려드립니다. 새로 고침이 실패하면이 NSLog
문 출력이 표시되지 않습니다.
새로운 데이터가있을 때 테이블보기를 다시로드하는 것에 대해 누락 된 것이 있습니까?
편집 내 -refreshTableDataSet
방법에서
: 내 테이블보기에서
- (void) refreshTableDataSet {
NSSortDescriptor *_objectTypeSorter = [[[NSSortDescriptor alloc] initWithKey:@"object.type" ascending:YES] autorelease];
NSSet *_objectSet = [managedObjectContext fetchObjectsForEntityName:@"Object" withPredicate:[NSPredicate predicateWithFormat:[NSString stringWithFormat:@"group.name like '%@'", [group name]]]];
self.objects = [[[_objectSet allObjects] sortedArrayUsingDescriptors:[NSArray arrayWithObjects: _objectTypeSorter, nil]] retain];
}
-tableView:cellForRowAtIndexPath:
방법 :
...
Object *_object = [self.objects objectAtIndex:indexPath.row];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = _object.name;
cell.detailTextLabel.text = _object.type;
cell.imageView.image = [UIImage imageNamed:@"GroupType.png"];
cell.accessoryView = [self imageViewForObjectDetailType:_object.type];
...
나는 accessoryView하는 방법이 -imageViewForObjectDetailType
, 단지 수익을 불렀다 a UIImageView
:
return [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"GenericObjectDetailType.png"]] autorelease];
누락 된 메시지가 retain
및/또는 release
입니까?
NSArray 설정 방법을 보여주는 코드를 추가했습니다. 내가 뭔가 빠진 것 같니? 감사! –
나는 잘못된 곳에서 나의'if (cell == nil)'테스트를 받았다. 나는 switch-case 트리를 가지며 각 case 블록으로 조건을 옮겨야 만했다. 당신의 철저한 아이디어에 감사드립니다. –
좋은 sleuthing! – mahboudz