Locking to Portrait on app launching rotates from Landscape to Portrait (iOS)









up vote
1
down vote

favorite












I want to lock the orientation of the first screen of the app to portrait. In some screens, I need landscape orientation. I am using the react-native-orientation plugin. But when I launch the application, I see landscape orientation for a while and then quickly rotating to portrait orientation. The next screens are ok.



Here is my code:



componentDidMount() 
Orientation.lockToPortrait();



Is it possible to solve this performance issue?










share|improve this question























  • do you want to disable the landscape orientation for all screens in your app?
    – Nino9612
    yesterday










  • @Nino9612 No, in some screens I need landscape orientation.
    – Vladimír
    yesterday










  • hmm okay. For which platforms are you developing?
    – Nino9612
    yesterday










  • @Nino9612 For iOS and Android. But this problem is only in iOS.
    – Vladimír
    yesterday











  • Have you tried Orientation.lockToPortrait() outside of component lifecycle method may be at app.js?
    – Prasun
    yesterday














up vote
1
down vote

favorite












I want to lock the orientation of the first screen of the app to portrait. In some screens, I need landscape orientation. I am using the react-native-orientation plugin. But when I launch the application, I see landscape orientation for a while and then quickly rotating to portrait orientation. The next screens are ok.



Here is my code:



componentDidMount() 
Orientation.lockToPortrait();



Is it possible to solve this performance issue?










share|improve this question























  • do you want to disable the landscape orientation for all screens in your app?
    – Nino9612
    yesterday










  • @Nino9612 No, in some screens I need landscape orientation.
    – Vladimír
    yesterday










  • hmm okay. For which platforms are you developing?
    – Nino9612
    yesterday










  • @Nino9612 For iOS and Android. But this problem is only in iOS.
    – Vladimír
    yesterday











  • Have you tried Orientation.lockToPortrait() outside of component lifecycle method may be at app.js?
    – Prasun
    yesterday












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I want to lock the orientation of the first screen of the app to portrait. In some screens, I need landscape orientation. I am using the react-native-orientation plugin. But when I launch the application, I see landscape orientation for a while and then quickly rotating to portrait orientation. The next screens are ok.



Here is my code:



componentDidMount() 
Orientation.lockToPortrait();



Is it possible to solve this performance issue?










share|improve this question















I want to lock the orientation of the first screen of the app to portrait. In some screens, I need landscape orientation. I am using the react-native-orientation plugin. But when I launch the application, I see landscape orientation for a while and then quickly rotating to portrait orientation. The next screens are ok.



Here is my code:



componentDidMount() 
Orientation.lockToPortrait();



Is it possible to solve this performance issue?







ios react-native






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 17 hours ago









Hannes

2,70822941




2,70822941










asked yesterday









Vladimír

10110




10110











  • do you want to disable the landscape orientation for all screens in your app?
    – Nino9612
    yesterday










  • @Nino9612 No, in some screens I need landscape orientation.
    – Vladimír
    yesterday










  • hmm okay. For which platforms are you developing?
    – Nino9612
    yesterday










  • @Nino9612 For iOS and Android. But this problem is only in iOS.
    – Vladimír
    yesterday











  • Have you tried Orientation.lockToPortrait() outside of component lifecycle method may be at app.js?
    – Prasun
    yesterday
















  • do you want to disable the landscape orientation for all screens in your app?
    – Nino9612
    yesterday










  • @Nino9612 No, in some screens I need landscape orientation.
    – Vladimír
    yesterday










  • hmm okay. For which platforms are you developing?
    – Nino9612
    yesterday










  • @Nino9612 For iOS and Android. But this problem is only in iOS.
    – Vladimír
    yesterday











  • Have you tried Orientation.lockToPortrait() outside of component lifecycle method may be at app.js?
    – Prasun
    yesterday















do you want to disable the landscape orientation for all screens in your app?
– Nino9612
yesterday




do you want to disable the landscape orientation for all screens in your app?
– Nino9612
yesterday












@Nino9612 No, in some screens I need landscape orientation.
– Vladimír
yesterday




@Nino9612 No, in some screens I need landscape orientation.
– Vladimír
yesterday












hmm okay. For which platforms are you developing?
– Nino9612
yesterday




hmm okay. For which platforms are you developing?
– Nino9612
yesterday












@Nino9612 For iOS and Android. But this problem is only in iOS.
– Vladimír
yesterday





@Nino9612 For iOS and Android. But this problem is only in iOS.
– Vladimír
yesterday













Have you tried Orientation.lockToPortrait() outside of component lifecycle method may be at app.js?
– Prasun
yesterday




Have you tried Orientation.lockToPortrait() outside of component lifecycle method may be at app.js?
– Prasun
yesterday












2 Answers
2






active

oldest

votes

















up vote
1
down vote













Add below code in your page where orientation lock is delayed:



componentWillMount()
Orientation.lockToPortrait();
Orientation.addOrientationListener(this._orientationDidChange);


_orientationDidChange(orientation)
Orientation.lockToPortrait();


componentWillUnmount()
// remove listener
Orientation.removeOrientationListener(this._orientationDidChange);






share|improve this answer




















  • It didn't help.
    – Vladimír
    14 hours ago

















up vote
0
down vote













react-native-orientation no longer seems maintained.



I encourage you to use react-native-orientation-locker which also provides Orientation.lockToPortrait()






share|improve this answer






















  • Result is the same as with react-native-orientation.
    – Vladimír
    yesterday










  • what is your device ? what is your OS version number ?
    – Julien Malige
    23 hours ago










  • My device is iPhone SE. iOS 12.0.1.
    – Vladimír
    23 hours ago










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53222179%2flocking-to-portrait-on-app-launching-rotates-from-landscape-to-portrait-ios%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













Add below code in your page where orientation lock is delayed:



componentWillMount()
Orientation.lockToPortrait();
Orientation.addOrientationListener(this._orientationDidChange);


_orientationDidChange(orientation)
Orientation.lockToPortrait();


componentWillUnmount()
// remove listener
Orientation.removeOrientationListener(this._orientationDidChange);






share|improve this answer




















  • It didn't help.
    – Vladimír
    14 hours ago














up vote
1
down vote













Add below code in your page where orientation lock is delayed:



componentWillMount()
Orientation.lockToPortrait();
Orientation.addOrientationListener(this._orientationDidChange);


_orientationDidChange(orientation)
Orientation.lockToPortrait();


componentWillUnmount()
// remove listener
Orientation.removeOrientationListener(this._orientationDidChange);






share|improve this answer




















  • It didn't help.
    – Vladimír
    14 hours ago












up vote
1
down vote










up vote
1
down vote









Add below code in your page where orientation lock is delayed:



componentWillMount()
Orientation.lockToPortrait();
Orientation.addOrientationListener(this._orientationDidChange);


_orientationDidChange(orientation)
Orientation.lockToPortrait();


componentWillUnmount()
// remove listener
Orientation.removeOrientationListener(this._orientationDidChange);






share|improve this answer












Add below code in your page where orientation lock is delayed:



componentWillMount()
Orientation.lockToPortrait();
Orientation.addOrientationListener(this._orientationDidChange);


_orientationDidChange(orientation)
Orientation.lockToPortrait();


componentWillUnmount()
// remove listener
Orientation.removeOrientationListener(this._orientationDidChange);







share|improve this answer












share|improve this answer



share|improve this answer










answered 18 hours ago









Sandy

1,3821520




1,3821520











  • It didn't help.
    – Vladimír
    14 hours ago
















  • It didn't help.
    – Vladimír
    14 hours ago















It didn't help.
– Vladimír
14 hours ago




It didn't help.
– Vladimír
14 hours ago












up vote
0
down vote













react-native-orientation no longer seems maintained.



I encourage you to use react-native-orientation-locker which also provides Orientation.lockToPortrait()






share|improve this answer






















  • Result is the same as with react-native-orientation.
    – Vladimír
    yesterday










  • what is your device ? what is your OS version number ?
    – Julien Malige
    23 hours ago










  • My device is iPhone SE. iOS 12.0.1.
    – Vladimír
    23 hours ago














up vote
0
down vote













react-native-orientation no longer seems maintained.



I encourage you to use react-native-orientation-locker which also provides Orientation.lockToPortrait()






share|improve this answer






















  • Result is the same as with react-native-orientation.
    – Vladimír
    yesterday










  • what is your device ? what is your OS version number ?
    – Julien Malige
    23 hours ago










  • My device is iPhone SE. iOS 12.0.1.
    – Vladimír
    23 hours ago












up vote
0
down vote










up vote
0
down vote









react-native-orientation no longer seems maintained.



I encourage you to use react-native-orientation-locker which also provides Orientation.lockToPortrait()






share|improve this answer














react-native-orientation no longer seems maintained.



I encourage you to use react-native-orientation-locker which also provides Orientation.lockToPortrait()







share|improve this answer














share|improve this answer



share|improve this answer








edited yesterday

























answered yesterday









Julien Malige

840723




840723











  • Result is the same as with react-native-orientation.
    – Vladimír
    yesterday










  • what is your device ? what is your OS version number ?
    – Julien Malige
    23 hours ago










  • My device is iPhone SE. iOS 12.0.1.
    – Vladimír
    23 hours ago
















  • Result is the same as with react-native-orientation.
    – Vladimír
    yesterday










  • what is your device ? what is your OS version number ?
    – Julien Malige
    23 hours ago










  • My device is iPhone SE. iOS 12.0.1.
    – Vladimír
    23 hours ago















Result is the same as with react-native-orientation.
– Vladimír
yesterday




Result is the same as with react-native-orientation.
– Vladimír
yesterday












what is your device ? what is your OS version number ?
– Julien Malige
23 hours ago




what is your device ? what is your OS version number ?
– Julien Malige
23 hours ago












My device is iPhone SE. iOS 12.0.1.
– Vladimír
23 hours ago




My device is iPhone SE. iOS 12.0.1.
– Vladimír
23 hours ago

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53222179%2flocking-to-portrait-on-app-launching-rotates-from-landscape-to-portrait-ios%23new-answer', 'question_page');

);

Post as a guest














































































這個網誌中的熱門文章

Is there any way to eliminate the singular point to solve this integral by hand or by approximations?

Why am i infinitely getting the same tweet with the Twitter Search API?

Solve: $(3xy-2ay^2)dx+(x^2-2axy)dy=0$