GLKit -drawRect: not called during screen rotation

I have a based application GLKitwith some simple displayable object.

Everything works fine, except for the rotation of the screen, during which GLKViewit is not updated ( -drawRect:not called). Thus, during rotation, the projection matrix is ​​not updated in accordance with dynamically changing screen sizes, and the object looks bad (stretches).

+5
source share
3 answers

This is simply not how UIKit animations work. I will explain how half of this works in this answer , but I will try to generalize the corresponding bits:

  • . ( , , CAShapeLayer, .)
  • UIView CALayer. .
  • .
  • - . UIViewAnimationOptionBeginFromCurrentState .

, , (CAShapeLayer , , UIScrollView , UIView - ...).

, , -setFrame:, (, , ), . , , , , ( ) , .

, GLKView -. GLKViewController, . -setNeedsDisplay , , .

, , fudging ( , ).

VC- , ( , , , "" / VC).

+1

, GLKit, UIView -drawRect:. contentMode , :

view.contentMode = UIViewContentModeRedraw;

, . UIView ( contentMode UIViewContentModeScaleToFill). , , , , UIView - .

+6

, , - .

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

, .

[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(deviceOrientationDidChange:) name: UIDeviceOrientationDidChangeNotification object: nil];

Then we implement the -deviceOrientationDidChange:view in your controller and call-setNeedsDisplay

0
source

All Articles