ここに私の問題があります:私のアプリには、ビューを切り替えることができるツールバーがあります。メインのもの、または少なくとも起動時のものは横向きモードで、他のビューに移動すると縦向きになります。問題は、最初のもの (横向き) に戻ろうとしたときに発生し、ビューが縦向きに表示されるため、すべてのビューが間違って表示されます。(それは多かれ少なかれ明確ですか? 乱雑に見える場合は申し訳ありません)。私がここに持っているいくつかのコード:
V1コントローラー:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
V2コントローラー:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-(IBAction)goToV1 {
V1Controller *v1 = [[V1Controller alloc] init];
[self.view.superview addSubview:v1.view];
}
ビューを追加する前に、オブジェクト v1 で何かをすることはできますか? わかりません、あなたの助けが必要です。
解決された問題 ビューの遷移で、1 つの文が欠落していました。現在のビューをスーパービューから削除します。また、@Bradが言っていたこと。ありがとうございました。
-(IBAction)goToV1 {
V1Controller *v1 = [[V1Controller alloc] init];
[self.view.superview addSubview:v1.view];
[self.view removeFromSuperview];
}