Ответ 1
Да, я также сталкиваюсь с этим типом проблемы, сделаю одно, просто удаляем просмотр нижнего колонтитула.
Я использую анимацию в ячейке таблицы... Анимация отлично работает, когда ячейка полностью видима. Если какая-либо ячейка частично видима в это время из-за анимации, мое приложение разбивается по строке [_Mytableviewobject endUpdates];
Crash Log = Завершение приложения из-за неотображенного исключения "NSInternalInconsistencyException", причина: "Флаг остановки фрагмента ячейки должен быть больше, чем начальная доля"
раздел кода:
-(void)sectionHeaderView:(SectionHeaderView*)sectionHeaderView sectionOpened:(NSInteger)sectionOpened
{
//ENSLog(self, _cmd);
[_caseTable reloadData];
NSInteger countOfRowsToInsert = 1;
SectionInfo *sectionInfo = [self.sectionInfoArray objectAtIndex:sectionOpened];
sectionInfo.open = YES;
NSMutableArray *indexPathsToInsert = [[[NSMutableArray alloc] init] autorelease];
for (NSInteger i = 0; i < countOfRowsToInsert; i++)
{
[indexPathsToInsert addObject:[NSIndexPath indexPathForRow:i inSection:sectionOpened]];
}
NSMutableArray *indexPathsToDelete = [[[NSMutableArray alloc] init] autorelease];
NSInteger previousOpenSectionIndex = self.openSectionIndex;
if (previousOpenSectionIndex != NSNotFound)
{
SectionInfo *previousOpenSection = [self.sectionInfoArray objectAtIndex:previousOpenSectionIndex];
previousOpenSection.open = NO;
[previousOpenSection.headerView toggleOpenWithUserAction:NO];
NSInteger countOfRowsToDelete = 1;
for (NSInteger i = 0; i < countOfRowsToDelete; i++)
{
[indexPathsToDelete addObject:[NSIndexPath indexPathForRow:i inSection:previousOpenSectionIndex]];
}
}
// Style the animation so that there a smooth flow in either direction.
UITableViewRowAnimation insertAnimation;
UITableViewRowAnimation deleteAnimation;
if (previousOpenSectionIndex == NSNotFound || sectionOpened < previousOpenSectionIndex)
{
insertAnimation = UITableViewRowAnimationTop;
deleteAnimation = UITableViewRowAnimationBottom;
}
else
{
insertAnimation = UITableViewRowAnimationTop;
deleteAnimation = UITableViewRowAnimationTop;
}
// Apply the updates.
[_caseTable beginUpdates];
[_caseTable deleteRowsAtIndexPaths:indexPathsToDelete withRowAnimation:deleteAnimation];
[_caseTable insertRowsAtIndexPaths:indexPathsToInsert withRowAnimation:insertAnimation];
[_caseTable endUpdates];
//ExNSLog(self, _cmd);
self.openSectionIndex = sectionOpened;
//ExNSLog(self, _cmd);
}
-(void)sectionHeaderView:(SectionHeaderView*)sectionHeaderView sectionClosed:(NSInteger)sectionClosed
{
//ENSLog(self, _cmd);
SectionInfo *sectionInfo = [self.sectionInfoArray objectAtIndex:sectionClosed];
sectionInfo.open = NO;
NSInteger countOfRowsToDelete = [_caseTable numberOfRowsInSection:sectionClosed];
if (countOfRowsToDelete > 0)
{
NSMutableArray *indexPathsToDelete = [[[NSMutableArray alloc] init] autorelease];
for (NSInteger i = 0; i < countOfRowsToDelete; i++)
{
[indexPathsToDelete addObject:[NSIndexPath indexPathForRow:i inSection:sectionClosed]];
}
[_caseTable deleteRowsAtIndexPaths:indexPathsToDelete withRowAnimation:UITableViewRowAnimationTop];
}
self.openSectionIndex = NSNotFound;
//ExNSLog(self, _cmd);
}
Да, я также сталкиваюсь с этим типом проблемы, сделаю одно, просто удаляем просмотр нижнего колонтитула.
Я испытал тот же самый крах при попытке использовать фиктивный нижний колонтитул для удаления потенциальных "пустых" ячеек таблицы.
Решение заключалось в том, чтобы избавиться от
tableView:viewForFooterInSection:
tableView:heightForFooterInSection:
и замените их следующим: viewDidLoad:
tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
похоже, что когда set tableview
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
а стиль tableview
style Plain
вместо Grouped
style
У меня возникла такая же проблема после обновления ios 7: во время "deleteRowsAtIndexPaths" произошел сбой при расширении/сворачивании материала в моем представлении таблицы.
Удивительно, но я решил эту проблему, используя heightForHeaderInsection вместо heightForFooterInSection.
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ return 1; // it was 0 before the fix } -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ return 0; // it was 1 before the fix }
Об этой проблеме сообщалось (https://devforums.apple.com/message/795349).
Вы можете использовать заголовок следующего раздела мой же ответ здесь
Для людей, переживших эту проблему после обновлений iOS 7: Проверьте рамку представления нижнего колонтитула раздела. Если он перекрывается с ячейкой tableview. Система выбрасывает это исключение.
Это ошибка в iOS. Я подал сообщение об ошибке, и они вернулись, сказав, что это дубликат 14898413. Эта ошибка по-прежнему отмечена как открытая в репортере Apple.
Варианты исправлений: 1) Удалить нижний колонтитул 2) Вместо удаления строк начало и конец обновлений перезагружают таблицу
Я получал ту же ошибку и аварийную ситуацию, когда я прокручивал нижнюю часть таблицы и пытался удалить ячейки и вставить разделы. Мое решение состояло в том, чтобы прокрутить представление таблицы вверх до вызова [tableview beginsUpdates]
, используя смещение содержимого tableviews, С помощью этого решения мне не пришлось менять заголовок или нижний колонтитул.
[self.tableView setContentOffset:CGPointZero animated:NO];
Я решил эту ошибку, вызвав reloadData() для последнего раздела:
func expandSectionPressed(sender: UIButton) {
let object = items[sender.tag]
object.expanded = !object.expanded
sender.selected = object.expanded
var indexPaths = [NSIndexPath]()
for i in 0..<7 {
indexPaths.append(NSIndexPath(forRow: i, inSection: sender.tag))
}
if object.expanded {
tableView.insertRowsAtIndexPaths(indexPaths, withRowAnimation: .Fade)
} else {
// strange crash when deleting rows from the last section //
if sender.tag < numberOfSectionsInTableView(tableView) - 1 {
tableView.deleteRowsAtIndexPaths(indexPaths, withRowAnimation: .Fade)
} else {
tableView.reloadData()
}
}
}
У меня возникла одна и та же проблема - исключение: фракция остановки фрагмента анимации должна быть больше, чем начальная доля в [[self tableView] endUpdates]; Я решил это, поймав исключение и сделав endUpdates вторым раз.
[[self tableView] beginUpdates];
@try
{
[[self tableView] endUpdates];
}
@catch (NSException* exception)
{
[[self tableView] endUpdates];
}