Modalità ritratto e paesaggio iOS
-
21-12-2019 - |
Domanda
Ho il seguente scenario:
Da AppDelegate faccio:
firstViewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
UINavigationController *firstNavController = [[UINavigationController alloc]initWithRootViewController:firstViewController];
.
firstviewcontroller - deve essere solo in modalità verticale
Per realizzare questo ho fatto:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
.
Da firstViewController
I Am Premendo un altro controller di visualizzazione che deve avere sia le funzionalità ritratto che di paesaggio.
Il secondViewController
agisce come previsto - in modalità portait e paesaggio
Ho problemi con FirstviewController che viene visualizzato anche in modalità orizzontale, anche se ne ho limitato in modalità verticale.Cosa sto facendo male?
Soluzione
Aggiungi la categoria UinavigationController con il seguente metodo nel tuo progetto
#import "UINavigationController+MyNavigation.h"
@implementation UINavigationController (MyNavigation)
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}
.
Questo ha risolto il mio problema.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow