更新:私はそれがいつも同じビューを読み込んでいた理由を発見しました。私はそれを修正しました。これは、タイプミスオリエンテーションの変更を表示
ControllerForSplitViews.m
- (id)init
{
self = [super initWithNibName:@"ControllerForSplitViews" bundle:nil];
if(UIInterfaceOrientationIsLandscape(self.interfaceOrientation)){
self.view = landscapeView;
}
if(UIInterfaceOrientationIsPortrait(self.interfaceOrientation)){
self.view = portraintView;
}
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
return self;
}
この作品でした。
今問題です。ビューが読み込まれて実行されているときに、向きを変えて同じnibファイルから別のビューを読み込むようにしました。固定しますが、これを実行すると直ちに他のUI要素が消えて横表示のui要素のみが保持されます。デバイスをもう一度回転すると、縦書きビューが再び表示されませんか?これがどうして起こるのか?
-(void) orientationChanged:(id)object
{
if(UIInterfaceOrientationIsPortrait(self.interfaceOrientation))
{
self.view = portraintView;
}
if(UIInterfaceOrientationIsLandscape(self.interfaceOrientation))
{
self.view = landscapeView;
}
}
という新たな問題、それは逆向きのビューロード
あなたの使用例UIViewControllerクラスです。では、すべてのUIViewControllerのUIViewControllerRotationカテゴリはどうですか? - '(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;などの回転のためのいくつかのメソッドがあります。 - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation; ' – beryllium