2011-09-17 14 views
0

iPhoneの標準iPodアプリケーションに似た効果を得る正しい方法は何ですか?デバイスを横向きに回転すると、ビューはフローをカバーするように変更されますが、遷移の種類は消えていて、回転する画面はありませんか?IOSが回転アニメーションなしのデバイスを回転する

- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { 
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) { 
     carouselView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
     [self presentModalViewController:carouselView animated:YES]; 
    } 
} 

ありがとう:

これは、私は、モーダルビューをロードしています方法です!

Andrius

答えて

2

私は後でこのソリューションを使用する方が安定していることがわかった:viewDidLoadメソッドは、これを追加する(私の場合、それはタブ・ビュー・コントローラである)親ビューコントローラで

を:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:@"UIDeviceOrientationDidChangeNotification" object:nil]; 

してから、このメソッドを追加:

- (void) didRotate:(NSNotification *)notification {  

    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; 
    if (UIInterfaceOrientationIsLandscape(orientation) && !self.modalViewController) { 
     [self presentModalViewController:carouselView animated:YES]; 
     [Globals sharedGlobals].startedAtLandscape = YES; 
    } 

    if (UIInterfaceOrientationIsPortrait(orientation) && self.modalViewController) { 
     [self dismissModalViewControllerAnimated:YES];  
     [Globals sharedGlobals].startedAtLandscape = NO; 
    } 
} 

そして最後の場合を回転アニメーションを防止するには、次のようにこのメソッドを変更します。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    if(UIInterfaceOrientationIsLandscape(interfaceOrientation)) { 
     return NO; 
    } 
    return YES; 
} 
+0

presentModalViewControllerは非推奨です。 –

関連する問題