如何使用完成块更新UI

问题描述

我正在使用Pod在某些基于页面的视图控制器中显示图像。窗格中内置了一个功能,可以为导航到另一张照片设置动画,但是此功能没有内置的完成处理程序。我想知道是否有一种方法可以将此函数包装在完成块中,因此可以保证在UI动画完成后执行代码。我尝试将函数包装在UIView.animate()块中,这种方法虽然有效,但使动画的呈现有点麻烦。谢谢!

这是我现在拥有的代码

UIView.animate(withDuration: 0.5,animations: {
    if (self.photosViewController.dataSource.numberOfPhotos == 1) {
      // dismiss view controller
    } else {
      if (currPhotoIndex == 0) {
        self.photosViewController.navigatetoPhotoIndex(currPhotoIndex + 1,animated: true)
        currPhotoIndex = 0
      } else {
        self.photosViewController.navigatetoPhotoIndex(currPhotoIndex - 1,animated: true)
        currPhotoIndex -= 1
      }
    }
  }) { (completion) in
    art.delete()
  }
})

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)