在断言失败 - [UITableView的_endCellAnimationsWithContext: [英] Assertion failure in -[UITableView _endCellAnimationsWithContext:

查看:1192
本文介绍了在断言失败 - [UITableView的_endCellAnimationsWithContext:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我充其量是业余的,并且停留在这个错误!当然简单的东西...

   - (无效)addTapped:(ID)发送{
TechToolboxDoc * newDoc = [[TechToolboxDoc页头] initWithTitle:@新建项目thumbImage:无fullImage:无];
[_itemArray ADDOBJECT:newDoc];
//[self.tableView beginUpdates];NSIndexPath * indexPath = [NSIndexPath indexPathForRow:_itemArray.count-1切入口:0];
NSArray的* indexPaths = [NSArray的arrayWithObject:indexPath];
的NSLog(@%@,indexPath);[self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:YES];[self.tableView selectRowAtIndexPath:indexPath动画:是的scrollPosition:UITableViewScrollPositionMiddle];
[个体经营performSegueWithIdentifier:@MySegue发件人:个体经营];   //[self.tableView endUpdates];

这是破坏就行了说

  [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:YES];


解决方案

您需要添加<一个href=\"https://developer.apple.com/library/ios/documentation/uikit/reference/UITableView_Class/index.html#//apple_ref/occ/instm/UITableView/beginUpdates\"相对=nofollow> [UITableView的beginUpdates] [UITableView的endUpdates] 周围:

  [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:YES];

从类引用:


  

请注意这种方法的行为时,它被称为一个动画
  由beginUpdates和endUpdates方法定义的块。 UITableView的
  推迟行或部分的任何插入,直到它已处理后
  行或部分的缺失。这种情况排序不分
  的插入和删除的方法调用。这不同于插入
  或在一个可变的阵列除去一个项目,在操作可能会影响
  用于连续插入或取出数组索引
  操作。欲了解更多关于这个问题,见批量插入,删除,
  并在表视图中的行和部分编程指南重装
  iOS版。


I'm an amateur at best, and stuck on this error! surely something simple...

- (void)addTapped:(id)sender {
TechToolboxDoc *newDoc = [[TechToolboxDoc alloc] initWithTitle:@"New Item" thumbImage:nil fullImage:nil];
[_itemArray addObject:newDoc];
//[self.tableView beginUpdates];

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:_itemArray.count-1 inSection:0];
NSArray *indexPaths = [NSArray arrayWithObject:indexPath];
NSLog(@"%@",indexPath);

[self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:YES];

[self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionMiddle];
[self performSegueWithIdentifier:@"MySegue" sender:self];

   //[self.tableView endUpdates];

it is breaking on the line the says

 [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:YES];

解决方案

You need to add [UITableView beginUpdates] and [UITableView endUpdates] around:

[self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:YES];

From the class reference:

Note the behavior of this method when it is called in an animation block defined by the beginUpdates and endUpdates methods. UITableView defers any insertions of rows or sections until after it has handled the deletions of rows or sections. This happens regardless of ordering of the insertion and deletion method calls. This is unlike inserting or removing an item in a mutable array, where the operation can affect the array index used for the successive insertion or removal operation. For more on this subject, see Batch Insertion, Deletion, and Reloading of Rows and Sections in Table View Programming Guide for iOS.

这篇关于在断言失败 - [UITableView的_endCellAnimationsWithContext:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆