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

相關問題