이것은 정말 나를 미치게합니다.새 행을 스크롤하고 삽입 한 후 이상한 UITableView 동작
정렬 된 고객 목록을 표시하는 테이블보기가 있습니다. 사용자는 새 고객을 추가 할 수 있으므로 테이블 뷰에 새 행을 추가해야합니다 (데이터 모델을 업데이트하고 insertRowsAtIndexPaths:withRowAnimation:
로 호출). 그러나 테이블보기가 정렬되기 때문에이 삽입은 화면 외부에서 발생할 수 있습니다. 이는 매우 좋지 않습니다. 사용자 경험. 그래서 내 생각은 삽입이 실제로 행을 삽입하기 전에 발생합니다 인덱스 경로에 테이블 뷰를 스크롤 할 수 있었다 :
- (void)finishedSavingNewCustomer:(Customer*)customer atIndex:(NSInteger)index {
// NOTE: self.customers (which is the model for the table view used in all datasource
// methods) has already been updated at this point, ie. it already contains the new customer
// scroll the table view so that the insert position is on-screen
NSInteger scrollRow = (index < ([self.customers count] - 1) ? index : [self.customers count] - 2);
NSIndexPath* scrollIndexPath = [NSIndexPath indexPathForRow:scrollRow inSection:0];
[self.tableView scrollToRowAtIndexPath:scrollIndexPath atScrollPosition:UITableViewScrollPositionNone animated:NO];
// insert the new row
NSArray* indexPaths = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:index inSection:0]];
[self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade];
}
이 코드는 실제로 예상대로 작동 : 테이블 뷰 스크롤 및 새 행이 올바르게 삽입됩니다.
그러나 삽입 후 일부 테이블보기 셀은 "irresponsive"이됩니다. 스 와이프시 삭제 버튼을 표시하지 않으며 선택시 강조 표시하지 않습니다. 이것이 정말로 이상하고 설명하기가 어렵 기 때문에 설명해 보도록하겠습니다.
초기 상황 : 행은 1-5이 표시됩니다
--------- screen top --------
Row 1
Row 2
Row 3
Row 4
Row 5
------- screen bottom -------
Row 6
Row 7
Row 8
Row 9
상황을 스크롤 삽입 후 :
Row 1
Row 2
Row 3
Row 4
Row 5
--------- screen top --------
Row 6
Row 7
Row 7a << newly inserted
Row 8
Row 9
------- screen bottom -------
이제 삽입 행 1 - 5로 사용자 상호 작용에 응답하지 않습니다 전술 한 바와.
아무도 이런 종류의 문제가 발생하지 않았습니까? 아이디어? 새로운 행 삽입이 사용자에게 표시되는지 확인하는 다른 방법이 있습니까?
업데이트 : 그냥 장치에서 테스트하고,이 문제는 시뮬레이터에서 발생 밝혀! 이것은 문제를 덜 불편하게하지만 다른 누군가가이 행동을 경험했다면 나는 여전히 흥미를 느낍니다.
두 가지 제안이 저에게 효과적이지는 않지만 시뮬레이터에서는 분명히 버그입니다. 테이블보기를 다시로드해도 도움이되지 않습니다! 어쨌든, 경험을 공유해 주셔서 감사합니다. –
언제든지. 다음과 같이 버그 보고서를 제출할 수 있습니다. https://bugreport.apple.com/ – Tim