UIViews flickering when gravity angle is adjusted?

47 Views Asked by At

So, I'm about to submit my first app to the App Store, but I'm having an issue with UIView handling. My app adjusts the angle of a UIGravityBehavior (which is applied to UIViews), and everything is fine, but when the ViewController containing the views is dismissed and called back up, the views' background color(a UIImage) is either flickering or invisible. Here is the code for the gravity adjustment; taking out this bit seems to solve the problem.

if motionManager.accelerometerAvailable {
  motionManager.accelerometerUpdateInterval = 0.1
  motionManager.startAccelerometerUpdatesToQueue(NSOperationQueue()) {(data, error) in
    dispatch_async(dispatch_get_main_queue()) {
      var xx = data!.acceleration.x
      var yy = data!.acceleration.y
      self.gravity.angle = CGFloat(atan2(xx, yy))
    }            
  }
}

Can anyone help me out?

0

There are 0 best solutions below