希望你一切都好,尽力而为。
我在 iOS 6
的 upSideDown Orientation
中遇到问题,虽然我认为我做的一切都很完美,但我不知道为什么它不起作用对我来说。我正在与您分享我的问题,以便获得任何解决方案。
到目前为止我做了什么:
a) 在 xcode 项目摘要选项卡中,我启用了所有 4 个方向。
b) 我在我所有的 Controller 类中添加了一段代码(写在下面)。
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
但 upSideDown 方向
仍然不起作用
感谢期待。
最佳答案
我找到了它的解决方案。
我们需要制作一个单独的 UINavigation Controller
类。在.m
文件中添加以下方法
// Deprecated in iOS6, still needed for iOS5 support.
// ---
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
// return (interfaceOrientation == UIInterfaceOrientationPortrait);
return YES;
}
// iOS6 support
// ---
- (BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAll;
}
现在将这个新创建的类分配给 Storyboard中的Navigation Controller
。还要在“项目 -> build设置 -> 编译源”中添加此类的 .m
文件。运行该项目,它将支持并执行所有方向,包括 upSideDown
。
希望对大家有所帮助。
问候
关于objective-c - upSideDown iPhone 方向在 iOS 6 中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13720907/