gpt4 book ai didi

ios - -[UITableView _endCellAnimationsWithContext : 中的断言失败

转载 作者:行者123 更新时间:2023-12-01 18:57:05 28 4
gpt4 key购买 nike

我充其量只是一个业余爱好者,并坚持这个错误!肯定是一些简单的事情......

- (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];

它正在打破线上的说法
 [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:YES];

最佳答案

您需要添加 [UITableView beginUpdates] [UITableView endUpdates]大约:

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

从类引用:

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.

关于ios - -[UITableView _endCellAnimationsWithContext : 中的断言失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26033504/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com