我像这样创建一个 GLKViewController
:
// Create a GLK View Controller to handle animation timings
_glkVC = [[GLKViewController alloc] initWithNibName:nil bundle:nil];
_glkVC.preferredFramesPerSecond = 60;
_glkVC.view = self.glkView;
_glkVC.delegate = self;
_glkVC.paused = YES;
NSLog(@"initial state: %@", _glkVC.paused ? @"paused" : @"running");
但它立即开始调用委托(delegate)更新方法,上面 NSLog
的输出是:initial state: running
我正在使用 setNeedsDisplay
管理我的 View 更新,但我希望 GLKViewController
不时处理动画,因此我只想在需要时取消暂停。有没有办法在暂停状态下启动 Controller ?
最佳答案
您是否尝试过在 viewDidAppear 方法而不是 viewDidLoad 方法中暂停?它应该看起来像这样:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
// self.paused automatically set to NO in super's implementation
self.paused = YES;
}
繁荣,完成!如果这可行,那么您每分钟保存数千次“if”检查,只是为了在启动时暂停!
关于ios - 如何创建以暂停状态启动的 GLKViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13021527/