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 defaults to portrait even though I have set the view controller to landscape. The orientation works correctly for iOS 8.
I tried to set the native page to landscape using the following code but it's not working:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
Any help would be appreciated.
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:
In NativePagesInHybridApp.h, add the
WLActionReceiver
protocol to the interface, i.e.:In NativePagesInHybridApp.m, add the implementation:
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...