I\'m developing a hybrid app using Worklight Studio 6.2 for iOS. The application should be forced to landscape orientation. In iOS 7, when I call a native page, the orientation
Update: We also have a fix for the issue when using WL.NativePage.show
.
You will need to open a PMR in order to receive a version with this fix.
It is strange that it's not working in iOS 7 but does in iOS 8. If you want you can open a PMR to have the Worklight development team look into it.
That said, the orientation does work correctly when using the SendAction
API, available starting Worklight 6.2.
The SendAction API basically allows you to send a 'command' - an action, to the native side and with this action you can do whatever you want. For example, open a View Controller of your own that you will have full control over it, which is much better than what WL.NativePage.show
allows you.
The below example is based on the NativePagesInHyridApp sample project from the Getting Started page.
In common\js\main.js you send an action where required:
function openNativePage(){
...
...
WL.App.sendActionToNative("openViewController");
}
In NativePagesInHybridApp.h, add the WLActionReceiver
protocol to the interface, i.e.:
@interface MyViewController : MyViewController <WLInitWebFrameworkDelegate, WLActionReceiver> {
}
In NativePagesInHybridApp.m, add the implementation:
@implementation MyAppDelegate
-(void)onActionReceived:(NSString *)action withData:(NSDictionary*) data{
NSLog(@"onActionReceived :: %@", action);
[self performSelectorOnMainThread:@selector(addViewController) withObject:nil waitUntilDone:YES];
}
-(void)addViewController{
HelloNative *helloNativeViewController = [[HelloNative alloc] init];
[self.window.rootViewController addChildViewController:helloNativeViewController];
[self.window.rootViewController.view addSubview:helloNativeViewController.view];
}
...
...
Now, when you launch the app and click the button, the generated view controller will be displayed - in landscape as well.
In the above example, a view controller is implemented in code, but you could create your own with a XIB or one created in Storyboard and call it up...