swift - 使用dispatch_async动画重新加载tableviewcell

标签 swift animation uitableview

我的单元格中有一个图标,当按下fav按钮时,我想显示它而不重新加载整个表格

所以我使用:

dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.tableView.reloadData()
})

这会立即重新加载表格,我想要一个流畅的动画。 我发现这个,似乎它适用于 ObjectiveC,我怎样才能在 swift 中做到这一点?

/Put this code where you want to reload your table view
dispatch_async(dispatch_get_main_queue(), ^{
        [UIView transitionWithView:<"TableName">
                          duration:0.1f
                           options:UIViewAnimationOptionTransitionCrossDissolve
                        animations:^(void) {
                            [<"TableName"> reloadData];
                        } completion:NULL];       
    }); 

最佳答案

看来可以用这个方法

class func transitionWithView(view: UIView, duration: NSTimeInterval, options: UIViewAnimationOptions, animations: () -> Void, completion: ((Bool) -> Void)?)

它与您在 OC 中使用的代码相同。

关于swift - 使用dispatch_async动画重新加载tableviewcell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32025162/

相关文章:

swift - 用选定的 TableViewCell 填充文本字段?

swift - 如何在 Swift 中管理 ViewController 之间的状态?

ios - 3 组件UIPickerView 制作3位数值

html - CSS缩放背景错误

uitableview - 有没有办法改变 UICollectionViews 的动画速度?

ios - 从 get 方法获取数据后 reloadData 不起作用

html - 溢出-X : hidden doesn't work with animation

javascript - `setTimeout` 设置为 1,为什么我的时钟跳秒?

ios - Tableview 在 UIViewController 上不可见

ios - 是否可以在一个 xib 中创建多个单元格?