2013-04-01 56 views
1

Xcode 4.6,有一個應用程序在哪裏支持IOS 5.0 當在IOS模擬器上運行應用程序6 - 自動旋轉工作時,IOS 5 - 沒有。 設備上的東西一樣。ios 5屏幕自動定位

二手StoryBoard。

注射能力自動旋轉時的布爾值 - 是。

+0

地方你的代碼。 – Ganapathy

回答

1

iOS6引入了新的方法來決定視圖是否應該旋轉,但對於iOS5,您仍然需要使用舊的方法 - 可能只是您使用的是iOS6方法。下面是我使用:

// New iOS6 autorotate interface. 
- (BOOL)shouldAutorotate 
{ 
    return YES; 
} 

- (NSUInteger)supportedInterfaceOrientations 
{ 
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) 
     return UIInterfaceOrientationMaskAllButUpsideDown; 
    else 
     return UIInterfaceOrientationMaskAll; 
} 

// Older autorotate interface (for compatibility). 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) 
     return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
    else 
     return YES; 
} 
+0

謝謝,但它不起作用。 我寫到AppDelegate.m的末尾 –

+0

它應該在視圖控制器類中,而不是AppDelegate.m。 –

+0

我在@implementation ViewController之後添加了這個塊,但它不起作用:( –

0

對於iOS5的使用

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
// Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
} 

但上述方法已經廢棄了iOS6的,以覆蓋此處,用下面這個

- (BOOL)shouldAutorotate { 
    return YES; 
} 

- (NSUInteger)supportedInterfaceOrientations { 
    return UIInterfaceOrientationMaskPortrait; 
} 
+0

我寫了它,但不會工作到AppDelegate.m –

+0

寫在正在呈現的視圖控制器 – hariszaman

+0

我在@implementation ViewController後添加了此塊,但它不起作用:( –