1

iOS 5 で正常に動作するアプリを持っています。iOS 6 で動作するようにアプリをアップグレードしようとしています。iOS 6 の向きの使用に関する多くの質問とチュートリアルを読みました。

私の問題は、rootViewController を呼び出すと問題なく動作することですが、viewController をプッシュすると、方向を使用してビューのサイズを変更するため、方向が非常に悪くなります (私のアプリは任意の方向をサポートします)。

ここに私のコードがあります:

AppDelegate:


UINavigationController *nav =[ [UINavigationController alloc] initWithRootViewController:theView]  ;
self.window.rootViewController = nav;


- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window  // iOS 6
{

return UIInterfaceOrientationMaskAll;


}




myFirstViewController:

-(NSUInteger)supportedInterfaceOrientations{

return UIInterfaceOrientationMaskAll;
 }

 -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{

    [self viewWillAppear:NO];
 }

 -(BOOL)shouldAutorotate{
 return YES;
  }

- (void)viewWillAppear:(BOOL)animated
{

[super viewWillAppear:NO];
if ( [[UIDevice currentDevice].systemVersion floatValue] >= 6.0){
    if (pointRange.location != NSNotFound) {



UIInterfaceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];

if( (interfaceOrientation >= 3)  ) {
     width=1024;
    self.view.frame=CGRectMake(0, 0, 1024, 768);

}


if   ( (interfaceOrientation == 1) || (interfaceOrientation == 2 )) {

    width=768;
    self.view.frame=CGRectMake(0, 0, 768, 1024);


}}
....etc

2番目のビューでも同じことをしました。理由を見つけたいと思います!!

4

2 に答える 2

0

私でさえ2日間苦しみました..多くのチュートリアル、ブログ、フォーラム、さらにはAppleドキュメントを調べました。

これまでのところ、iOS 6 では、アプリの各テンプレートを異なる方法で処理する必要があることを知りました。

これまでの議論はビュー ベースのアプリについてのみであり、これらの変更はナビゲーション ベースのアプリやタブバー ベースのアプリでは機能しませんでした。

最後に私は解決策を得ました、それはこのように

UITabBarControllerこれら 2 つの型またはのサブクラスを実装しUINavigationControllerます。

このブログで知りました。解決策を提供してくれた Shabbir に感謝します。

于 2012-11-01T13:21:36.433 に答える