plistファイルから取得したものの大きなリストを含むテーブルがあり、それぞれをクリックすると、新しいビューであるxibに移動します。
その.xib内に2つのビューがあります。1つはポートレート用、もう1つはランドスケープ用です。
私のhファイルにはこれがあります:
IBOutlet UIView *portraitView;
IBOutlet UIView *landscapeView;
@property (nonatomic, retain) IBOutlet UIView *portraitView;
@property (nonatomic, retain) IBOutlet UIView *landscapeView;
私のmファイルではこれ:
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
}
- (void) orientationChanged:(id)object
{
UIInterfaceOrientation interfaceOrientation = [[object object] orientation];
if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
self.view = self.portraitView;
}
else
{
self.view = self.landscapeView;
}
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
self.view = portraitView;
} else if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
self.view = landscapeView;
}
return YES;
}
@end
iOS 5ではすべてが完全に機能し、必要に応じて横向きまたは縦向きで表示されていました。
iOS 6アップデートでは、すべてが混乱します。
テーブル(縦)ビューで1つのアイテムをクリックすると、縦に正しく表示されます。横に回転すると、ビューにも正しいビューが表示されますが、テーブルに戻って選択すると、横になります。別のアイテムでは、横向きではなく縦向きのビューが表示されます。
私が同じことをしますが、最初の風景をすると、それは肖像画を示します。
そのため、オリエンテーションは何に対しても機能していません。
ストーリーボードを使用している他のビューにも同じことが起こります。それらは縦向きで、常にそのように表示されます。今では回転し、すべてを縮小し、アプリをゴミ箱として残します。
1- .xibの向きを修正するにはどうすればよいですか?
2-ストーリーボードの向きを修正するにはどうすればよいですか?(それらは静的でしたが、今ではすべてが回転します(コードはまったくありません))
ありがとう。