J'ai un globalstate dans mon application. Selon l'état, l'interface graphique est différente.Swift: dispatch_async est l'effet est incompatible pour l'animation
Quand je vais dès le début Voir A à B Voir I ont globalstate Il devrait afficher un écran d'information, mais il ne fonctionne pas. MAIS: Lorsque la View B est chargée une seule fois et que je passe de View C/D/E à View B, le code fonctionne parfaitement. (Vous devez être en vue A à entrer Voir B.)
J'utilise beaucoup dispatch_async (dispatch_get_main_queue .. ce n'est pas bon style, est-il?
Pourquoi mon animation ne se charge pas au ? commencer Qu'est-ce bon style Merci pour les réponses et désolé pour les erreurs (anglais n'est pas mon mothertongue)
override func viewDidLoad() {
super.viewDidLoad()
dispatch_async(dispatch_get_main_queue(), {
self.animateTheInformationViewWhenGlobalStateIsThree()
})
}
func animateTheInformationViewWhenGlobalStateIsThree() {
print("GLOGBALSTATE \(globalState)") //it is 3
if globalState == 3 {
setGlobalState(3)
dispatch_async(dispatch_get_main_queue(), {
GUITools.animateTheInformationView(self.tableView, animateBottomLayout: self.animationBottomConstraint, value: self.negativValue)
})
print("THE POSITIV VALUE THE NEGATIV")
}
// Guitools-statique classe:
class func animateTheInformationView(tableView: UITableView, animateBottomLayout: NSLayoutConstraint, value: CGFloat) {
dispatch_async(dispatch_get_main_queue(), {
animateBottomLayout.constant += value
UIView.animateWithDuration(Constants.animationTime, animations: {() -> Void in
tableView.layoutIfNeeded()
},completion: {
(value: Bool) in
})
})
}
EDIT Avec viewDidAppear
cela fonctionne. Mais l'animation n'est pas une vraie animation. Le tableauView "saute". Donc il n'y a pas de glissement/animation.
Je supprimé tous dispatch_async ..
override func viewDidAppear(animated: Bool) { self.animateTheInformationViewWhenGlobalStateIsSeven() }
homme, merci beaucoup! Et merci pour l'explication. – kuzdu