私はいくつかの言葉でテーブルビューを持っています、そして私はデバイスが回転するときのフラッシュカードスタイルの横向きのビューを提示します。「UIDeviceOrientationDidChangeNotification」を見て作りました。
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(openLandscapeMode) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
1)それは問題なくスムーズに機能しますが、問題は、私たちが風景の中にいるときに、ビューコントローラーが垂直軸の周りの回転に反応して、電話をテーブルに置くことができないようにすることです。まだ風景の中にあります。たぶん、デバイスの向きではなく、水平方向の回転をどうにかして観察する必要がありますか?
-(void)openLandscapeMode
{
if([[UIDevice currentDevice]orientation]==UIDeviceOrientationLandscapeLeft||[[UIDevice currentDevice]orientation]==UIDeviceOrientationLandscapeRight)
{
LandscapeCardViewController *landscape = [[LandscapeCardViewController alloc]init];
landscape.words = words;
landscape.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:landscape animated:YES];
NSLog(@"Switch to %@",[[NSUserDefaults standardUserDefaults]valueForKey:@"ChosenWordInCard"]);
[landscape release];
}
else
{
[self dismissModalViewControllerAnimated:YES];
[[UIApplication sharedApplication]setStatusBarOrientation:UIInterfaceOrientationPortrait];
}
}
2)2番目の質問は、このコントローラーがタブバーにあり、同じタブバーの別のコントローラーで同じトランジションを実行したいが、もちろん別のランドスケープビューを使用している場合、オブザーバーを削除する場所です。viewWillDissappearで試しましたが、正しく機能しません。どうもありがとう!