iPad UIInterfaceOrientation 启动图像后
我的应用程序应该仅支持横向模式,因此我配置 info.plist 键以正确的方式获取它。
我的根视图控制器是一个自定义 UINavigationController,我将其添加到主窗口并实现了
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}
问题是,在 applicationDidFinishLaunching 之后,interfaceOrientation
始终为 UIInterfaceOrientationLandscapeRight,即使应用程序以 UIInterfaceOrientationLandscapeLeft 方向启动也是如此。
结果是启动图像的方向正确,而应用程序是颠倒的。
摇动设备一段时间,使控制器再次按正确方向旋转。
这是一个错误吗?我该如何解决这个问题?
My application should support only landescape mode, so I configure the info.plist keys to get it in the right way.
My root viewcontroller is a custom UINavigationController that I add to the main window and which implement
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}
The problem is that, after applicationDidFinishLaunching, interfaceOrientation
is always UIInterfaceOrientationLandscapeRight even when the application was launched in UIInterfaceOrientationLandscapeLeft orientation.
The result is that the splash image is oriented properly, while the application is upsidedown.
Shaking the device for a while, make the controller rotate again in the correct direction.
Is it a bug? How do I solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这对我来说非常有用
(BOOL)shouldAutorotateToInterfaceOrientation(UIInterfaceOrientation)interfaceOrientation
{
if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
返回是;
}其他{
返回NO;
}
}
祝你好运
This works great for me
(BOOL)shouldAutorotateToInterfaceOrientation(UIInterfaceOrientation)interfaceOrientation
{
if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
return YES;
}else{
return NO;
}
}
Good luck