Swift3 在swift 3中执行请求时,我的图像停止动画

Swift3 在swift 3中执行请求时,我的图像停止动画,swift3,uiimageview,alamofire,grand-central-dispatch,uiviewanimation,Swift3,Uiimageview,Alamofire,Grand Central Dispatch,Uiviewanimation,我有一个UImage,它需要旋转,直到我对服务器的调用结束。 但我的图像只旋转一次,然后停止 我的代码: @IBOutlet var imgLoader: UIImageView! override func viewDidLoad() { super.viewDidLoad() DispatchQueue.global(qos: .userInitiated).async { self.getSalons() } self.lau

我有一个UImage,它需要旋转,直到我对服务器的调用结束。 但我的图像只旋转一次,然后停止

我的代码:

    @IBOutlet var imgLoader: UIImageView!
    override func viewDidLoad() {
    super.viewDidLoad()
    DispatchQueue.global(qos: .userInitiated).async {
        self.getSalons()
    }
    self.launchLoaderDesign()
    NotificationCenter.default.addObserver(forName:NSNotification.Name("LoadAllShowNotification"), object: nil, queue: nil, using: notificationFinish)
}

func getSalons() -> Void {
    let api:ApiSvain = ApiSvain()
    api.getHeartStrokeSalon()
    api.getSalonForHomePage()
}

func launchLoaderDesign() -> Void {
    var posImg:Int = 0
    UIView.animate(withDuration: 0.5, delay: 0, options: .curveEaseIn, animations: { () -> Void in
            self.imgLoader.transform = self.imgLoader.transform.rotated(by: CGFloat(M_PI_2))
    })
    { (finished) -> Void in
        self.launchLoaderDesign()
    }
}
func getSalonForHomePage(){
    let url = "MY_URL"
    Alamofire.request(url, method: .get).validate().responseJSON
    { response in
        if (response.error == nil)
        {
            let json = JSON(response.result.value!)

            for (index, element) in json
            {
                let show:Show = Show(json: element, index: index)
                StaticData.arrayOfShow.append(show)
            }
            NotificationCenter.default.post(name:NSNotification.Name("LoadAllShowNotification"), object: nil, userInfo: nil)
        }
        else
        {
            print(response.error!)
        }
    }
}
我的函数getSalonForHomePage发送一个通知,当我捕捉到它时,我使用performSegue移动到我的新页面

我认为我的问题来自于我对多线程的误解


Ps:我正在使用alamofire 4向我的服务器发送请求。

尝试在计时器中调用动画?你说的在计时器中调用动画是什么意思?请选中“尝试在计时器中调用动画”复选框?你说的在计时器中调用动画是什么意思?请选中