willPause: never called.

What could be the reason that my GLKViewController's willPause: method is never called?


-(void)glkViewController:(GLKViewController *)controller willPause:(BOOL)pause


I implemented this for my view controller, which derives from GLKViewController.

But a breakpoint in it, is never hit.


Targetting latest iOS SDK, using Xcode 9, and Objective C.

Accepted Reply

Ok, I figured out why it was not called.


GLKViewController can work in two ways:


  1. By subclassing GLKViewController and implementing methods for update: and drawInRect:
  2. By setting a GLKViewControllerDelegate.


The two are mutually exclusive.


willPause: is a method of the delegate, and not a method of GLKViewController.


Because I used subclassing, it will not be called.

It looks like I will have to catch the foregrounding/backgrounding in the AppDelegate instead, and find a way to my viewcontroller and have it handle it.

Replies

Using the <> code brackets in the editor, show your rendering loop code relative to calling willPause, thanks.

Ok, I figured out why it was not called.


GLKViewController can work in two ways:


  1. By subclassing GLKViewController and implementing methods for update: and drawInRect:
  2. By setting a GLKViewControllerDelegate.


The two are mutually exclusive.


willPause: is a method of the delegate, and not a method of GLKViewController.


Because I used subclassing, it will not be called.

It looks like I will have to catch the foregrounding/backgrounding in the AppDelegate instead, and find a way to my viewcontroller and have it handle it.