ios - Orientation Bug - Stuck in landscape -


i've got iphone app uiviewcontroller first controller. in it, i've got standard methods force landscape (see below).

i've got second view show modal in viewwillappear -- it's meant splash screen while pull down content 'net.

the problem happens when physically rotate device landscape mode , start app. modal shows (in portrait), when gets dismissed few seconds later, main view displayed in landscape.

on other hand, if comment out code modal , launch app in landscape, main view shows in portrait should.

any suggestions on how can keep main view in portrait mode when app launched landscape?

- (void)viewwillappear:(bool)animated {    // show loading splash screen until webview has completed    [self performseguewithidentifier:@"sgimagemodal" sender:self]; }  - (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender {    if ([segue.identifier isequaltostring:@"sgimagemodal"]) {             splashscreen.modalpresentationstyle = uimodalpresentationfullscreen;            } }  - (bool)shouldautorotate {     return no; }  - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation {     return (interfaceorientation == uiinterfaceorientationportrait); }  - (void)navigationcontroller:(uinavigationcontroller *)navigationcontroller willshowviewcontroller:(uiviewcontroller *)viewcontroller animated:(bool)animated {     [self viewwillappear:animated]; }  - (nsuinteger)supportedinterfaceorientations{     return uiinterfaceorientationmaskportrait; }  -(uiinterfaceorientation)preferredinterfaceorientationforpresentation {     return uiinterfaceorientationportrait; } 

update 1

as per suggestions, i've moved logic display modal viewdidappear , viewdidload. changed shouldautorotate return yes. neither had desired impact.

you can't present modal view controller until current view controller has finished it's loading, or finished it's transition. 90% of time, means have present modal view controller in viewdidappear: opposed viewwillappear:. problem is, when code executed in viewwillappear:, view may not finished it's setup (including figuring out orientation present in).

here handy answer jacob knobel explains when each view lifecycle method called.

therefore, if want splash screen appear right away, make present without animation, presenting viewdidappear:. upon launching application modal should appear right away.

edit - have tried returning yes shouldautorotate? you've specified supported interface orientations, , told it should automatically rotate if orientation portrait, you've told it shouldn't automatically rotate?


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -