기본 사용자 인터페이스로 UITableView가있는 iPhone 응용 프로그램을 작성하고 있습니다. 각 섹션은 머리글과 본문이라는 두 개의 행으로 구성됩니다. 그것은 작동하고셀을 다시로드하지 않고 UITableViewCell에서 이미지 변경
comp.contentsHidden = YES;
[self.tableView beginUpdates];
NSArray *deleteIndexPaths = [[NSArray alloc] initWithObjects:[NSIndexPath indexPathForRow:1 inSection:indexPath.section], nil];
[self.tableView deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade];
[self.tableView endUpdates];
: 나는 다음과 같은 코드를 사용하고 사용자가 헤더를 선택
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
cbwComponent *comp = [_componentController objectInListAtIndex:section];
if([comp hasContentsView] && !comp.contentsHidden){
return 2;
}else
return 1;
}
: 사용자가 헤더를 클릭하면, 나는 numberOfRowsInSection 값을 변경하여 두 번째 행을 제거 멋지고 부드러운 페이드 효과가 있습니다. 문제는 클릭 할 때 변경되는 표식기 (행 0)에 표시기를 추가하려고하는 것입니다. 그 이미지를 바꾸기 위해서는 두 번째 행뿐만 아니라 맨 위 행을 새로 고쳐야합니다. 그러면 두 번째 행이 전환을 좋지 않게 보입니다 (음, 거의 부드럽 지 않음). 셀을 새로 고치지 않고 UITableViewCell에서 이미지를 변경하는 방법이 있습니까?
감사합니다.
편집 : 알아 냈습니다. 두 번째 행을 변경하기 전에 첫 번째 행을 다시로드하는 한 부드러운 전환을 유지할 수 있습니다. [tableView beginUpdates] 내부에서 호출되어야합니다.
[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:[[NSArray alloc] initWithObjects:[NSIndexPath indexPathForRow:0 inSection:indexPath.section], nil] withRowAnimation:UITableViewRowAnimationNone];
...
[self.tableView endUpdates];
트릭을 했습니까?