I’m looking if -glkView:drawInRect: can detect that it’s drawing for -snapshot method, rather than the normal way, where the view will be displayed to the user. It’s so I can detect how to draw the view correctly. My attempt at detecting the difference in view was to compare the view passed to -glkView:drawInRect: with the GLKViewController’s view:
// standard function GLKViewController
- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
if ((self.view != view)) NSLog(@"drawing for snapshot");
// draw code ...
}
But no luck. Another method I was considering was to create a boolean variable that would be set whenever -snapshot is called and -glkView:drawInRect: would reset it after it has drawn the snapshot specific view. But that seems dirty, and may cause multiple bugs, especially if drawing at 60 fps.
Do you give any recommendations or examples for detecting if -glkView:drawInRect: is drawing for the -snapshot method?
Thanks in advance
Subclass
GLKViewand overwrite thesnapshotmethod to something like this:Instead of a property, you can also use a custom delegate to notify your view controller or post a
NSNotification.