[英]UITableViewController subView rotation
我是Stackoverflow和Objective-C編程的新手。 我已經搜索了下面描述的問題,但是找不到有效的解決方案。
我的應用程序是一個簡單的脫機瀏覽應用程序,具有導航結構。 在appDelegate中,我通過以下方式之一加載RootViewController(UITableViewController):
解決方案A
[window addSubview:navigationController.view];
[window makeKeyAndVisible];
return YES;
解決方案B
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)。 我想要的是僅在最后一個視圖中啟用自動旋轉。 對於所有先前的想法,肖像取向是期望的。 最后一個視圖以正確的方式實現:
應該AutorotateToInterfaceOrientation:interfaceOrientation
應該自動旋轉
willRotateToInterfaceOrientation:toInterfaceOrientation持續時間:持續時間
willAnimateRotationToInterfaceOrientation:interfaceOrientation持續時間:持續時間
覆寫
應該自動旋轉
應該AutorotateToInterfaceOrientation:interfaceOrientation
使他們在rootViewController中返回NO / YES,並使用所需的方式設置允許的方向,使用
支持的接口方向
(在rootViewCOntroller和最后一個視圖中),我得到的結果是:
我做錯了什么? 預先感謝您的幫助
將它們添加到您的viewController中,讓我知道它是否有效。
// iOS5旋轉
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
// iOS6旋轉
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
- (BOOL)shouldAutorotate
{
return YES;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.