UITableview用animation重新载入数据
Iam有一个从数组和下拉列表填充的UItableView。 如果我select下拉列表中的任何一行数组将插入新的值和tableview应该重新加载。 如何使用新的数组内容来animationtableview? 提前致谢
要添加到正确的答案,如果你想重新加载你的UITableView 所有部分,你将需要执行以下操作: 
ObjC
 NSRange range = NSMakeRange(0, [self numberOfSectionsInTableView:self.tableView]); NSIndexSet *sections = [NSIndexSet indexSetWithIndexesInRange:range]; [self.tableView reloadSections:sections withRowAnimation:UITableViewRowAnimationAutomatic]; 
迅速
 let range = NSMakeRange(0, self.tableView.numberOfSections) let sections = NSIndexSet(indexesIn: range) self.tableView.reloadSections(sections as IndexSet, with: .automatic) 
这将使用animation重新载入表格视图中的所有内容。 像一个老板一样。
使用这种方法,
 [_tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade]; 
 你首先告诉tableView预计更新beginUpdates 。 然后更新相关的部分(如果你的tableView只有一个部分,然后只传递零号的部分)。 这是您指定animation的地方 – 您可以使用它来获得所需的效果。 之后,你在tableView上调用endUpdates 。  UITableViewRowAnimation的typedef指定: 
 typedef enum { UITableViewRowAnimationFade, UITableViewRowAnimationRight, UITableViewRowAnimationLeft, UITableViewRowAnimationTop, UITableViewRowAnimationBottom, UITableViewRowAnimationNone, UITableViewRowAnimationMiddle, UITableViewRowAnimationAutomatic = 100 } UITableViewRowAnimation; 
 玩耍,看看你想要哪一个。 即使selectUITableViewRowAnimationNone也会有一个很好的效果。 下面的表更新代码: 
  [self.tableView beginUpdates]; [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone]; [self.tableView endUpdates]; 
Swift 3
 UIView.transition(with: myTableView, duration: 1.0, options: .transitionCrossDissolve, animations: {self.myTableView.reloadData()}, completion: nil) 
Swift 2
 UIView.transitionWithView(myTableView, duration: 1.0, options: .TransitionCrossDissolve, animations: {self.myTableView.reloadData()}, completion: nil) 
我在Swift中一起去了
 你可以使用reloadSections:withRowAnimation: functions。 检查UITableView类参考 。 
检查此reloadData与animation已经回答你的问题。
 在Swift 3中,您可以简单地将以下extension添加到UITableView : 
 extension UITableView { func reloadData(with animation: UITableViewRowAnimation) { reloadSections(IndexSet(integersIn: 0..<numberOfSections), with: animation) } } 
下面的方法由tableView支持animation:
 - (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation NS_AVAILABLE_IOS(3_0); 
用法:
 //Reload tableView with animation [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationRight]; 
可用的不同types的animation是:
 typedef NS_ENUM(NSInteger, UITableViewRowAnimation) { UITableViewRowAnimationFade, UITableViewRowAnimationRight, // slide in from right (or out to right) UITableViewRowAnimationLeft, UITableViewRowAnimationTop, UITableViewRowAnimationBottom, UITableViewRowAnimationNone, // available in iOS 3.0 UITableViewRowAnimationMiddle, // available in iOS 3.2. attempts to keep cell centered in the space it will/did occupy UITableViewRowAnimationAutomatic = 100 // available in iOS 5.0. chooses an appropriate animation style for you }; 
希望这可能有帮助!
在转换时尝试animation处理在重新加载UITableView时更改视图
 [UIView transitionWithView:_yourTableView duration:0.40f options:UIViewAnimationOptionTransitionCrossDissolve animations:^(void) {[_yourTableView reloadData];} completion:nil]; 
 我已经尝试了这一点,我的Table是Animated与平滑的animation 
//把这段代码放到你想要重载表格视图的地方
 dispatch_async(dispatch_get_main_queue(), ^{ [UIView transitionWithView:<"TableName"> duration:0.1f options:UIViewAnimationOptionTransitionFlipFromRight animations:^(void) { [<"TableName"> reloadData]; } completion:NULL]; });