2010-09-03 89 views
1

我有一個iPhone應用程序,我正在使用shouldAutorotateToInterfaceOrientation來確定何時自動旋轉。在iphone上,我指定UIInterfaceOrientationPortrait是唯一允許的方向;在iPad上,我只是返回YES(即所有允許的),像這樣:Ipad模擬器不自動旋轉

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) //also tried using [[UIDevice currentDevice] userInterfaceIdiom] to no avail 
    return YES; //doesn't get here 
return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

這是在標籤欄的每個視圖控制器。當我NSLog()[[UIDevice currentDevice] userInterfaceIdiom],它返回0(或UIUserInterfaceIdiomPhone)。

iPad模擬器是否總是返回UIUserInterfaceIdiomPhone

+0

可能重複[是否與目標設備的家庭UI_USER_INTERFACE_IDIOM工作(http://stackoverflow.com/questions/3167740/does-ui-user-interface-idiom-工作與目標設備家庭) – 2010-09-03 17:04:35

+0

這是我的答案:http://stackoverflow.com/questions/12565693/xcode-4-5-ios-6-0-simulator-orientation-not-working/12568678# 12568678 – gjpc 2012-09-24 17:50:49

回答