大佬教程收集整理的这篇文章主要介绍了ios – 为什么setEditing:animated:和insertRowsAtIndexPaths:导致这个奇怪的编辑风格动画?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
顶行做我想要的 – 它只是滑过,删除图标淡入.当它消失时,删除图标淡出,行再次展开.
第二行是我自己添加到表中的非数据源行.在出现时,它根本没有动画.插入图标和行一次出现,不会滑入.当它消失时,行会很好地展开,但加号图标会随之滑动.动画正在整个行中发生,而不是加号图标,然后分开行,就像第一行一样.
这是我的代码的快速破解,但我认为提供类文件的链接可能会更好.
按下工具栏上的编辑按钮时,我调用我的UIViewController方法setEdiTing:animated:.在这种方法中,@R_672_10673@下……
- (void)setEdiTing:(BOOL)ediTing animated:(BOOL)animated { [super setEdiTing:ediTing animated:animated]; // keep the table in the same ediTing mode [_table setEdiTing:ediTing animated:animated]; if (ediTing) { [_table insertRowsATindexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:_chAnnels.count inSection:0]] withRowAnimation:UITableViewRowAnimationNone]; } else { [_table deleteRowsATindexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:_chAnnels.count inSection:0]] withRowAnimation:UITableViewRowAnimationNone]; } }
这是插入的动画发生的地方.我已经尝试在[_table beginupdate]和endupdate中包装整个内容,以及只插入行.似乎都没有产生我想要的干净动画.
- (void)setEdiTing:(BOOL)ediTing animated:(BOOL)animated { _amEdiTing = ediTing; if (ediTing) { [_table insertRowsATindexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:_chAnnels.count inSection:0]] withRowAnimation:UITableViewRowAnimationNone]; } [super setEdiTing:ediTing animated:animated]; // keep the table in the same ediTing mode [self.view setEdiTing:ediTing animated:animated]; if (!ediTing) { [_table deleteRowsATindexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:_chAnnels.count inSection:0]] withRowAnimation:UITableViewRowAnimationNone]; } } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return _amEdiTing ? _chAnnels.count + 1 : _chAnnels.count; }
更新:
倒数第二行的图标仍然有一个奇怪的动画..要解决此问题,您可以添加延迟删除..
if (!ediTing) { [self performSELEctor:@SELEctor(deleteLastRow) withObject:nil afterDelay:0.25]; } -(void) deleteLastRow { [self.view deleteRowsATindexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:_objects.count inSection:0]] withRowAnimation:UITableViewRowAnimationNone]; }
以上是大佬教程为你收集整理的ios – 为什么setEditing:animated:和insertRowsAtIndexPaths:导致这个奇怪的编辑风格动画?全部内容,希望文章能够帮你解决ios – 为什么setEditing:animated:和insertRowsAtIndexPaths:导致这个奇怪的编辑风格动画?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。