iOS 6の自動回線のためにアプリを完全に正しく機能させる方法は?
-
11-12-2019 - |
質問
IOS6では、shouldAutorotateToInterfaceOrientation
は推奨されていません。AutoRotationのためにアプリを正しく動作させて失敗しました。
このViewController私は回転したくないが、うまくいきません。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-(BOOL)shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
.
任意のアイデア? 事前に助けてくれてありがとう!
解決
はそれを考え出した。
1)サブクラスuinavigationController (階層のTop ViewControllerは向きを制御します。)
Self.Window.RootViewControllerとして設定しました。
.
- (BOOL)shouldAutorotate
{
return self.topViewController.shouldAutorotate;
}
- (NSUInteger)supportedInterfaceOrientations
{
return self.topViewController.supportedInterfaceOrientations;
}
2)ビューコントローラを回転させたくない場合
.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-(BOOL)shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
-(BOOL)shouldAutorotate
{
return YES;
}
BTW、あなたのニーズに応じて、他の関連方法:
.- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskPortrait;
}
他のヒント
ルートコントローラとしてナビゲーションコントローラの代わりにタブバーコントローラを使用している場合は、uItabbarControllerをサブクラス化する必要があります。
も構文が異なります。私は成功して以下を使いました。その後、上書きしていたビューコントローラで上記の例を使用しました。私の場合私はメイン画面が回転しないことを望んでいましたが、私は私が自然に風景ビューを有効にしたいという映画を使ったよくある質問画面を持っていました。完全に働いた!Self.ModalViewControllerへの構文の変更を注意してください(ナビゲーションコントローラの構文を使用しようとすると、コンパイラ警告が表示されます。)これが役立つことを願っています!
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (BOOL)shouldAutorotate
{
return self.modalViewController.shouldAutorotate;
}
- (NSUInteger)supportedInterfaceOrientations
{
return self.modalViewController.supportedInterfaceOrientations;
}
.