Xcode ждет завершения анимации перед выполнением следующего задания

Вы можете попробовать использовать Unmanaged API метаданных , который является COM и может быть легко использован из приложения .NET с каким-то оберткой.

-4
задан TNasty 5 March 2019 в 05:44
поделиться

1 ответ

Эту проблему можно решить, добавив логическую переменную IF Statement вместе с функцией DispatchQueue, чтобы предотвратить появление другой анимации до завершения текущей анимации.

См. Ниже и, пожалуйста, upvote, если это вообще помогло:)

import UIKit
var animation_active = false
let animation_duration = 2 //For easy maintenance

func swipe_down() {
    if animation_active == false {
        animation_active == true
        //Animation code goes here. Variable 'animation_active' should be used when performing the animation for easy matinence
        DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(animation_duration), execute: {
            animation_active = false
        })
    }
}


func swipe_up() { //This is exactly the same as swipe_up. Yet it will prevent the swipe animation from occuring when the swipe down animation is occuruing thanks to the variable 'animation_active'
    if animation_active == false {
        animation_active == true
        //Animation code goes here. Variable 'animation_active' should be used when performing the animation for easy matinence
        DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(animation_duration), execute: {
            animation_active = false
        })
    }
}
0
ответ дан Matt L 5 March 2019 в 05:44
поделиться
Другие вопросы по тегам:

Похожие вопросы: