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番目のビューでも同じことをしました。理由を見つけたいと思います!!