作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个OpenGL游戏,需要了解设备的方向(即纵向与横向)。
这些API似乎非常简单... ViewController的相关部分包括:
@implementation MyViewController
- (id)init
{
...
// Get orientation events
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didRotate:)
name:@"UIDeviceOrientationDidChangeNotification" object:nil];
...
}
-(void)didRotate:(NSNotification*)notification
{
NSLog(@"didRotate %d", orientation);
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
{
NSLog(@"shouldAutorotateToInterfaceOrientation %d", orientation);
return YES;
}
@end
shouldAutorotateToInterfaceOrientation 3
shouldAutorotateToInterfaceOrientation 3
shouldAutorotateToInterfaceOrientation 3
shouldAutorotateToInterfaceOrientation 3
didRotate 4
shouldAutorotateToInterfaceOrientation 4
shouldAutorotateToInterfaceOrientation 4
didRotate 1
shouldAutorotateToInterfaceOrientation 1
最佳答案
好吧,这有点令人尴尬...
原来人像模式锁定已打开。
DOH!
关于ios - iOS:设备定向事件在启动后永远不会到来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10487659/
我遇到过 WinAPI 的奇怪行为,在我看来是这样。在我的程序中,我为窗口设置了一个计时器 ::SetTimer(window_handle, timer_id, 10, NULL); 并在我的窗口过
我是一名优秀的程序员,十分优秀!