While developing React Native Mobile Applications we often face challenges regarding device orientation. Common issues that we face are -
- Get device Orientation
- Lock application to portrait mode
- Lock application to landscape
- Lock application to portrait mode and enable landscape mode for some screens only
for all those requirements listed above, we use the react-native-orientation library.
To setup the library follow the steps given in the documentation of react-native-orientation. follow the URL given below-
While setting up the library keep this thing in mind that in case of iOS linking the documentation says that you have to add following lines in AppDeligate.m file -
- (UIInterfaceOrientationMask)application:(UIApplication *)application
supportedInterfaceOrientationsForWindow:(UIWindow *)window {
while ([[UIDevice currentDevice] isGeneratingDeviceOrientationNotifications]) {<
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
}
return [Orientation getOrientation];
}
What I have noticed is that after making this change we will see some issues in iOS. Such that -
- OrientaionListener is not working after lockToPortrait() or lockToLandscape() or UnlockAllOrientation()
- lockToPortrait() or lockToLandscape() or UnlockAllOrientation() are not working
- The device is not coming back to portrait mode after switching to landscape mode
- The device is not coming back to landscape mode after switching to portrait mode
To fix all those issues we need to make the below change. Instead of adding the lines sown above you only have to add the lines below-
- (UIInterfaceOrientationMask)application:(UIApplication *)application
supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return [Orientation getOrientation];
}
Because while loop in this creating problem and because of this some times orientation listeners are not getting triggered.
You. Are. A. GENIUS!
ReplyDelete
ReplyDeletesuch an interesting post shared by you
Python course in Delhi
Python course in Noida
ReplyDeleteThanks for sharing the information
python training institute in south delhi
python training institute in Noida
https://newtecho5.blogspot.com/
ReplyDeleteMicrosoft propelled Windows Phone in October 2010. So Windows Phone is relatively more youthful than other two versatile stages. download itools crack
ReplyDeleteDiscover the advantages of versatile auto body repair administration.Iphone reparatur
ReplyDeleteRight off the bat, Android Inc. was an autonomous organization, later Google purchased that organization in 2005 and sold their first Android Smartphone in 2008. Then, iOS fueled Smartphone had acquired 2008 only a year prior to Android for iPhone by Apple Inc. kodi addons
ReplyDeleteI Updated the list.iTools Crack"
ReplyDeleteThis is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here keep up the good work Iosemus
ReplyDeleteReally i appreciate the effort you made to share the knowledge. The topic here i found was really effective to the topic which i was researching for a long time basicknowledgehub
ReplyDelete