Bonjour, je viens de terminer l’app nombre mystère et je bloqué sur le problème du la rotation de l’écran, dans le cous maxime utilise viewWillLayoutSubviews() pour gérer la rotation j’ai voulu effectuer la même chose mais cela ne fonctionné pas j’ai du utilisé le fonction viewDidLayoutSubviews() est-ce une erreur du cours ou une erreur dans mon code ?
voici mon code:
override func viewDidLayoutSubviews() {
updateDisplay()
super.viewDidLayoutSubviews()
}
func updateDisplay() {
let barwidth = ui_gameView.bounds.width
let barwidthRatio = barwidth / CGFloat(GameManager.INTERVAL)
if _gameManager.isGameInProgress {
let barwidth = ui_gameView.bounds.width
let barwidthRatio = barwidth / CGFloat(GameManager.INTERVAL)
ui_newGameButton.isHidden = true
ui_intructionLabel.isHidden = false
ui_minHelpLabel.text = String(_gameManager.minBoundarie)
ui_MaxHelpLabel.text = String(_gameManager.maxBoundarie)
ui_newGameOnGameButton.isHidden = false
if ui_gameView.isHidden {
UIView.transition(with: ui_gameView, duration: 0.4, options: [.transitionCurlDown], animations: {
self.ui_gameView.isHidden = false
}, completion: nil)
}
cs_maxBar.constant = (CGFloat(GameManager.MAX_VALUE - _gameManager.maxBoundarie) * barwidthRatio)
cs_minBar.constant = (CGFloat(GameManager.MIN_VALUE + _gameManager.minBoundarie) * barwidthRatio)
ui_textFieldStackView.isHidden = false
}else {
ui_newGameButton.isHidden = false
ui_intructionLabel.isHidden = true
ui_minHelpLabel.text = String(_gameManager.minBoundarie)
ui_MaxHelpLabel.text = String(_gameManager.maxBoundarie)
ui_newGameOnGameButton.isHidden = true
UIView.transition(with: ui_gameView, duration: 0.4, options: [.transitionCurlUp], animations: {
self.ui_gameView.isHidden = true
}, completion: nil)
cs_maxBar.constant = (CGFloat(GameManager.MAX_VALUE - _gameManager.maxBoundarie) * barwidthRatio)
cs_minBar.constant = (CGFloat(GameManager.MIN_VALUE + _gameManager.minBoundarie) * barwidthRatio)
ui_textFieldStackView.isHidden = true
}
}