gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 14:08:40 26 4
gpt4 key购买 nike

我的单元格中有一个图标,当按下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/

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