All rights are reserved by Niteesh Kumar.. Theme images by Storman. Powered by Blogger.

Followers

Total Pageviews

Blog Archive

Follow by Email

Translate

Tuesday, 13 August 2019

React Native Orientation not working iOS



While developing React Native Mobile Applications we often face challenges regarding device orientation. Common issues that we face are - 

  1. Get device Orientation
  2. Lock application to portrait mode 
  3. Lock application to landscape 
  4. 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 - 
  1. OrientaionListener is not working after lockToPortrait() or lockToLandscape() or UnlockAllOrientation()
  2. lockToPortrait() or lockToLandscape() or UnlockAllOrientation() are not working
  3. The device is not coming back to portrait mode after switching to landscape mode
  4. 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. 




7 on: "React Native Orientation not working iOS "
  1. Microsoft propelled Windows Phone in October 2010. So Windows Phone is relatively more youthful than other two versatile stages. download itools crack

    ReplyDelete
  2. Discover the advantages of versatile auto body repair administration.Iphone reparatur

    ReplyDelete
  3. Right 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

    ReplyDelete