5

希望你会好起来,尽力而为。upSideDown iPhone方向不适用于iOS 6?

我在我的iOS 6得到一个问题upSideDown Orientation,而我认为我做的一切都是最好的,但我不知道为什么它不是为我工作。我与你分享我的问题,以获得任何解决方案。

我迄今所做的:

一)在Xcode项目摘要选项卡,我已经启用了所有的4个方向。

b)中我在我的所有控制器类的添加一段代码(以下写的)。

-(BOOL)shouldAutorotate 
{ 
    return YES; 
} 
-(NSInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskAll; 
} 

但仍然upSideDown Orientation不工作在期待

感谢。

回答

8

我找到了它的解决方案。

我们需要制作一个单独的类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; 
} 

现在指定这个新创建的类添加到您的Navigation Controller在故事板。在“项目 - >生成设置 - >编译源”中添加该类的.m文件。运行该项目,它将支持并执行所有方向,包括upSideDown

我希望它能帮助你。

问候

+0

另一种方法是创建'UINavigationController'类别为这里所做的:http://stackoverflow.com/a/16052448/211292 – ThomasW

+0

我需要它仅适用于iPhone与iOS 7,检测PortraitOrientationUpSideDown。 – Beto

相关问题