Re: Create a landscape only iPad app with Phonegap

5,172 views
Skip to first unread message

JMF

unread,
Jul 2, 2012, 2:13:08 PM7/2/12
to phon...@googlegroups.com
At work we have Xcode 4.3.2 and PhoneGap 1.4.1. Whenever I build an app with these versions, the content rotates along with the "application wrapper". On another laptop, I am running Xcode 4.5 DP2 and PhoneGap 1.9. Any apps I build with this, the app will work landscape but the web page/content inside remains in portrait. I can't figure out what is causing this difference to occur. Is the new Xcode 4.5 incompatible with PG? Or was something changed after 1.4.1 that I need to be aware of?

Thanks.

Robert Winterbottom

unread,
Jul 2, 2012, 2:42:28 PM7/2/12
to phon...@googlegroups.com
Im not using XCode on my work machine unfortunately, Im using Notepad++, but what I have done is create a phonegap config.xml file, you can google it and find a few samples that will get you started, but the  preference I have used to force landscape only is this <preference name="orientation" value="landscape" /> , place this in your config.xml and you should be good to go.  Also, after creating the config.xml, place it in the same directory as your index.html file

On Saturday, June 30, 2012 3:44:11 PM UTC-4, JMF wrote:
Hello,

I have searched and searched for this but cannot find an answer. I want to create an iPad-only app with Phonegap, and I want it to only launch and run in widescreen format. I've got the HelloWorld app to run, but I can't get it to run in landscape mode at all.

In XCode, I have chosen my app to be iPad only, and I have configured the Plist file for the supported interface orientations to be Landscape with left and right home buttons. I do not have any portrait options entered, and I have deselected both portrait and upside down on the Summary tab.

Is the code to determine the orientation written somewhere within the Cordova web files? I couldn't find anything there, either. If this is the case, where might I change it and what is the appropriate code to disable portrait completely?

As a complete novice, I would appreciate any and all help on this. Thank you.

JMF

JMF

unread,
Jul 2, 2012, 2:59:12 PM7/2/12
to phon...@googlegroups.com
Thanks. I did exactly as you said but when I run the app, the content remains portrait event though the app itself is landscape. I installed the older PG 1.4.1 on my laptop running Xcode 4.5 DP2 and I have the same problem. I wonder if there is something new in Xcode 4.5 that affects PG projects. The laptop is a test machine running Mountain Lion, so the current version of Xcode can't be installed onto it to test my theory.

Is placing the config.xml file inside the Xcode project sufficient or does it have to be referenced somewhere by something, and maybe that is what I am doing wrong?

Thanks.

Robert Winterbottom

unread,
Jul 2, 2012, 3:06:29 PM7/2/12
to phon...@googlegroups.com
It may be sufficent, but I think in XCode they create a www folder and that would be where you would most likely want to put it, Im kind of new to phonegap as well, been using it for two weeks. I am currently in the process of learning Objective-C because I am kind of a mac nerd but I havent tried phonegap on my mac at home, only on my work machine, which is windows, and here I place it in the root directory with my index.html, if it is not working, you can try specifying a newer version of phonegap in the config.xml using <preference name="phonegap-version" value="1.7.0" /> but I am not sure if this will work if you are building via xcode.

JMF

unread,
Jul 2, 2012, 3:11:37 PM7/2/12
to phon...@googlegroups.com
The only thing I am doing with Xcode is implementing the Phonegap stuff. I'm not writing any Objective C at all. I, too, am new to this stuff and am just confused why one version of Xcode does exactly as it's supposed to on one machine and the other doesn't work correctly. I'm really beginning to think that Xcode 4.5 isn't fully compatible with Phonegap 1.9 but the only way I can think to test this is to partition the laptop and reinstall 10.7 and its version of Xcode.

Thanks for the information. I wish I could find a solution.

Robert Winterbottom

unread,
Jul 2, 2012, 4:25:12 PM7/2/12
to phon...@googlegroups.com
It's definitely a possibility, well good luck.

Kerri Shotts

unread,
Jul 2, 2012, 6:05:13 PM7/2/12
to phon...@googlegroups.com
Are you testing on an iOS 6 device or targeting iOS-6? If so, I can discuss it with you, but off-list. [NDA]

JMF

unread,
Jul 2, 2012, 9:08:20 PM7/2/12
to phon...@googlegroups.com
Yes, I am working on an iOS 6 device. The best way to reach me is via email: iammichaelbower[at]gmail.com. Thanks.

anurag gautam

unread,
Jul 3, 2012, 12:41:18 AM7/3/12
to phon...@googlegroups.com
Hello 
   
There is an    <projectname>-info.plist in your xcode under resources folder.

 You have to change set   Portrait (bottom home button) value under  Supported interface orientations 
Try an enjoy




happy coding :)


On Tue, Jul 3, 2012 at 6:38 AM, JMF <iammich...@gmail.com> wrote:
Yes, I am working on an iOS 6 device. The best way to reach me is via email: iammichaelbower[at]gmail.com. Thanks.

-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
 
To compile in the cloud, check out build.phonegap.com



--
Thanks!
With regards
ANURAG GAUTAM
7814155605
Linkedin profile


JMF

unread,
Jul 3, 2012, 9:07:18 AM7/3/12
to phon...@googlegroups.com
Thanks, I've already tried this and it still doesn't work. I heard there are changes to the webkit API in iOS 6, and that might be the reason it's not functioning as expected.

Noli Sicad

unread,
Jul 4, 2012, 12:34:56 AM7/4/12
to phon...@googlegroups.com
I think this is phonegap 1.9.0 issue with the new SDK.

Why? Since if you have iOS 6.0 ipad simulator running and drop your
index.html to the simulator, then you rotate the simulator to
landscape, the content of index.html will display landscape as well.

However, in the previous version of PhoneGap with older SDK, this thing works.

Any of you not using the new Xcode4.5 preview 2 with PhoneGap 1.9.0?
Please try to see if this issue is not present i.e. working landscape
mode with your iPad project.

Noli

Noli Sicad

unread,
Jul 6, 2012, 2:03:16 AM7/6/12
to phon...@googlegroups.com
It is not PhoneGap 1.9.0 for iOS that has the problem.

It is iOS 6.0 SDK with media query CSS and PhoneGap 1.9.0.

I manage to include iOS 5.0 SDK in Xcode 4.5 preview 2 and run
properly PG 1.9.0 with content rotation.

Noli

Kerri Shotts

unread,
Jul 10, 2012, 12:27:54 AM7/10/12
to phon...@googlegroups.com
I have a solution that works on my devices, so I'd like to toss it out there for others to try. It seems to behave as one would expect on iOS 5 and 6. 

Part of the problem is that the MainViewController is not set to be the rootViewController in AppDelegate.m. This should have clued me in when I saw messages from the console indicating that there wasn't a root controller, but it didn't quite click. Once I looked closer, I made the following change to AppDelegate.m:

Instead of 

[self.window addSubview:self.viewController.view];

replace it with 

self.window.rootViewController = self.viewController;

At this point orientation is handled correctly, but for one problem: the webview doesn't appear to know the dimensions of the status bar, and tries to display content underneath it. I tried all sorts of things, and finally got this to work, in viewDidLoad: of MainViewController.m:

After

    [super viewDidLoad];

    // Do any additional setup after loading the view from its nib.

add

    self.webView.frame = CGRectMake ( 0, 20, self.view.frame.size.width, self.view.frame.size.height-20);

This is, of course, horrible, since I'm making the assumption that the status bar is present and also 20px high, but for my app it is, so I'm not bothering with the check. It seems to work fine on the simulator and device in iOS 5 and 6, though there's got to be a better way to handle the frame of the webview.

If you wouldn't mind giving it a go, I'd love to hear if it works for you or if it blows up... Something inside me says this is too easy!

JMF

unread,
Jul 11, 2012, 10:45:48 AM7/11/12
to phon...@googlegroups.com
Thanks, I will give this a try once I get the chance. If I don't care about the status bar being visible (in the app I am working on I don't want it present anyway) do I need to worry about your "fix"? If all I do is the first part, would I be good to go?

I'm sorry I don't understand the tech stuff as much. I'm better with the web stuff and have no knowledge of XCode or Obj C, so it's all confusing to me.

Thanks very much for posting this. I can't wait to try it and see how I fare.

Kerri Shotts

unread,
Jul 11, 2012, 11:17:58 PM7/11/12
to phon...@googlegroups.com, phon...@googlegroups.com
If your status bar is invisible, then yes, you only need to worry about the first part -- the view will then fill the entire screen. In my case, I wanted the status bar to be displayed (and not translucent), so I had to add the 20px to get the view to resize correctly.

______________________________
Kerri Shotts
photoKandy Studios LLC

📱 Phone: +1 (312) 380-1035
🌐 Web: http://photokandy.com 

Twitter: @photokandy

-- You received this message because you are subscribed to the Google

Phonegappin

unread,
Sep 20, 2012, 7:53:55 PM9/20/12
to phon...@googlegroups.com
This saved me a lot of headaches.  Thank you for posting this solution!

My iPad landscape only app was suddenly coming up with the view laying on it's side. (portrait view while the pad was landscape)

-Derek

Michael Falck Wedelgård

unread,
Sep 21, 2012, 3:38:03 PM9/21/12
to phon...@googlegroups.com
Thank you!!!! This worked like a charm.

Abhi

unread,
Sep 30, 2012, 10:38:29 PM9/30/12
to phon...@googlegroups.com
iPad apps supposed to be usable in both orientations as per Apple user interface guidelines. Keynote app does not all though

Sent from my iPhone

On 1 Oct, 2012, at 7:10 AM, "Rachel_:-)" <teddys...@gmail.com> wrote:

Fantastic! Thank you for your help. Just upgraded to Xcode 4.5 and was working with one of my apps when I noticed that the orientation wasn't working. Found out that it is an issue with Xcode, but couldn't find a fix. Your code did the trick. Though the app is still only rotating in three dimensions, that is good enough for me.

Sometimes, well most of the time, upgrading Xcode builds, are fraught with land mines.

Thanks to you, there is one less thing to worry about.

-Rachel

--
Reply all
Reply to author
Forward
0 new messages