Software Archive
Read-only legacy content
17061 Discussions

IOS build - orientation not working

hsdk_k_
Beginner
727 Views

Hi,

 I've currently tried building for an ipad through the intel xdk and noticed that the orientation settings aren't working. I've set mine to 'landscape', but I still notice that when I turn my ipad around, the app still switches between landscape <-> portrait. Are there any plans to fix this?

 I was also wondering how the status on developing for only ipad apps were going (currently only able to develop universal apps, which makes it impossible to develop apps for only ipad) - I asked the question about a year ago and again last month, but as of now, an update doesn't seem to be on the way. 

0 Kudos
8 Replies
John_H_Intel2
Employee
727 Views

The portrait/landscape only sets the initial orientation of the app (on start up). You need to use javascript to lock it to landscape if you want it to remain in landscape at all times.

https://software.intel.com/en-us/node/493051

0 Kudos
Renato_B_
Beginner
727 Views

 

Hi John

Sorry to reopen this thread, but I've this same issue. I'm trying to lock the orientation to landscape and I can't. I know about the solution to cli 5 but I need to build the app in cli4 because I'm using a plugin that only works in this way. 

This solution that you/intel provided still works? 

If yes, where I have to include this code?

//lock in "portrait" orientation 
intel.xdk.device.setRotateOrientation("portrait");

Thanks

 

 

0 Kudos
Swati_S_Intel1
Employee
727 Views

You can include the set orientation code after the device ready event - In your code ondeviceready() or onappready() function.

0 Kudos
Renato_B_
Beginner
727 Views

Hi Swati

I included this code in the index.html

        <script>
document.addEventListener("intel.xdk.device.ready", onDeviceReady, false);               
function onDeviceReady(){
    // set orientation
    intel.xdk.device.setRotateOrientation('landscape');
//    intel.xdk.device.setRotateOrientation('portrait');
//    intel.xdk.device.setRotateOrientation('any');

    intel.xdk.device.hideSplashScreen();   
}        
    </script>

After:

    <script src="intelxdk.js"></script>

But didn't work. It's not right?

0 Kudos
Renato_B_
Beginner
727 Views

My application needs to stay in panorama mode but only appears in portrait. I had specified the landscape option in C2 and XDK, and included the script also, but nothing changes. I really need some assistance about this issue. I started my tries to fix this problem more than week ago. Please, some help.

0 Kudos
Renato_B_
Beginner
728 Views

?

0 Kudos
Renato_B_
Beginner
728 Views

I've to maintain both deviceready event listeners

    <script src="cordova.js"></script>
    
    <!-- The runtime script.  You can rename it, but don't forget to rename the reference here as well.
    This file will have been minified and obfuscated if you enabled "Minify script" during export. -->
    <script src="c2runtime.js"></script>

    <script>
        jQuery(window).resize(function() {
            cr_sizeCanvas(jQuery(window).width(), jQuery(window).height());
        });
        
        document.addEventListener("deviceready", function ()
        {
            window["c2iscordova"] = true;
            
            // Create new runtime using the c2canvas
            cr_createRuntime("c2canvas");
            
            document.addEventListener("pause", function() {
                cr_setSuspended(true);
            }, false);
            
            document.addEventListener("resume", function() {
                cr_setSuspended(false);
            }, false);
            
        }, false);
    
    </script>

 

0 Kudos
Anusha_M_Intel1
Employee
728 Views

Check out this FAQ: https://software.intel.com/en-us/xdk/faqs/cordova#app-orientation

 

0 Kudos
Reply