2013-04-26 55 views
0

我是新來的stackoverflow和Objective-C編程。我已經搜索了下面描述的問題,但我無法找到工作解決方案。UITableViewController子視圖旋轉

我的應用程序是一個簡單的離線瀏覽應用程序,具有導航結構。 在的appDelegate我加載RootViewController的(的UITableViewController)以下列方式之一:

​​

溶液

RootViewController* rootviewcontroller = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];  
    navigationController = [[UINavigationController alloc] initWithRootViewController:rootviewcontroller]; 

的RootViewController的簡單地按下某些視圖,即

TipAndTrickViewController *mTipAndTrick = [[TipAndTrickViewController alloc]initWithNibName:@"TipAndTrickViewController" bundle:nil]; 
[self.navigationController pushViewController:mTipAndTrick animated:YES]; 

在更深的視圖中,我介紹了一個詳細的modalView(UIViewController)。 我想要的只是在最後一個視圖中啓用自動旋轉。目前的方向是所有以前的作品所期望的。最後一個視圖實現以正確的方式:

shouldAutorotateToInterfaceOrientation:interfaceOrientation

shouldAutorotate

willRotateToInterfaceOrientation:toInterfaceOrientation 持續時間:持續時間

willAnimateRotationToInterfaceOrientation:interfaceOrientation 持續時間:持續時間

重寫

shouldAutorotate

shouldAutorotateToInterfaceOrientation:interfaceOrientation

使它們在RootViewController的返回NO/YES和設置在所期望的方式允許的取向,使用

supportedInterfaceOrientations

(無論是在RootViewController的,並在最後一個視圖),我得到這些結果:

  • 如果我使用的解決方案一個各方面的意見不旋轉。
  • 如果我使用解決方案B所有的視圖總是旋轉。

我在做錯了什麼? 預先感謝您的幫助

回答

0

將這些添加到您的viewController並讓我知道它是否有效。

// iOS5的旋轉

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return YES; 
} 

// iOS6的旋轉

- (NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskAll; 
} 

- (BOOL)shouldAutorotate 
{ 
    return YES; 
} 
+0

正如我在文章的激射部分描述我想這個實現,但不幸的是,它不工作,得到A液和B分別 – rivand 2013-04-27 08:31:14