The Orientation Method lockToLandscape() method is defaulting the view to landscape but doesn't actually lock landscape or disable portrait. If I flip the orientation back to portrait, it allows it to switch back to portrait.
I would think that it would actually lock the view to landscape it will disable all other orientations. Does this library support this? Am I missing something?
Any help would much appreciated!
@yamill any ideas on this?
Related #136
Hello @larryranches just you have to try this:
in AppDelegate.m adding both two lines
#import "../../node_modules/react-native-orientation/iOS/RCTOrientation/Orientation.h"
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return [Orientation getOrientation];
}
@lavarajallu Is there a more general react-native-ish approach for this? Rather then deep editing of node-modules?
@lavarajallu I tried this but still not working. Any suggestions?
Here's my AppDelegate.m:
#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "../../node_modules/react-native-orientation/iOS/RCTOrientation/Orientation.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"teste"
initialProperties:nil
launchOptions:launchOptions];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return YES;
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return [Orientation getOrientation];
}
@end
also tried #import "Orientation.h"
This works for me:
#import "AppDelegate.h"
#import "Orientation.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"Broccoli"
initialProperties:nil
launchOptions:launchOptions];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return YES;
}
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return [Orientation getOrientation];
}
@end
I posted a solution here https://github.com/yamill/react-native-orientation/issues/136#issuecomment-290476178
Also created a repo with a working example: https://github.com/soutot/react-native-orientation-test
Hope it helps
But where it i can placed
On Aug 17, 2017 11:04 PM, "Tiago Souto" notifications@github.com wrote:
I posted a solution here #136 (comment)
https://github.com/yamill/react-native-orientation/issues/136#issuecomment-290476178Also created a repo with a working example: https://github.com/soutot/
react-native-orientation-testHope it helps
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/yamill/react-native-orientation/issues/121#issuecomment-323141277,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ATmTnAEmhD9imaWMQVtSI5RyGreMeUA7ks5sZHj0gaJpZM4LC3tY
.
@lavarajallu in my case I had to replace the import in my node_modules/react-native-orientation/iOS/Orientation.h to look like this: #import <React/RCTBridgeModule.h>
Let me know if it helps
Okay thanq
On Aug 17, 2017 11:54 PM, "Tiago Souto" notifications@github.com wrote:
@lavarajallu https://github.com/lavarajallu in my case I had to replace
the import in my node_modules/react-native-orientation/iOS/Orientation.h
to look like this: #importLet me know if it helps
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/yamill/react-native-orientation/issues/121#issuecomment-323154721,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ATmTnC1dV_bV6AP9YanGgGN3FG3Si23Oks5sZIVPgaJpZM4LC3tY
.
mr@GeoffreyPlitt you have to go in header search path in
$(SRCROOT)/../node_modules/react-native-orientation/iOS/RCTOrientation in recursive method go to settings
@soutot This work around fixed my issue on iOS.
See the sample of code here for the snippets of code to implement:
https://github.com/soutot/react-native-orientation-test/blob/master/ios/teste/AppDelegate.m
@wookelvin does it miss a } ? code is inside - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{ or outside ?
I have the same issue.
@JayricMok it should be after close } because the method is returned YES so it wont execute the code.
Most helpful comment
Hello @larryranches just you have to try this:
in AppDelegate.m adding both two lines