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 GLKView
and overwrite the snapshot
method to something like this:
- (UIImage *)snapshot
{
self.isDrawingSnapshot = YES;
UIImage *result = [super snapshot];
self.isDrawingSnapshot = NO;
return result;
}
Instead of a property, you can also use a custom delegate to notify your view controller or post a NSNotification
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.