Skip to content

Instantly share code, notes, and snippets.

@aheze
Last active October 29, 2020 19:01
Show Gist options
  • Save aheze/0200630955433ab67385065284784abc to your computer and use it in GitHub Desktop.
Save aheze/0200630955433ab67385065284784abc to your computer and use it in GitHub Desktop.
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
/// viewDidLoad() is often too early to get the first initial attitude, so we use viewDidLayoutSubviews() instead
if let currentAttitude = motionManager.deviceMotion?.attitude {
/// we populate initialAttitude with the current attitude
initialAttitude = currentAttitude
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment