Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

iPad top window offset - fixed

I know the top offset problem been an issue for many of us that's developing an iPad as the device requires full orientation modes support per Apple. The problem is if the app open in any orientation rather than top-down portrait mode, there's about 20 pixels offset (in my case) on top of the window. I think i found a get-around for iPad top offset. :) – append navbar last.

Cut to the chase, there are many bugs in iPad default images rendering and app open with incorrect orientation modes i wouldn't go in detail here. With 1.2, it does switch correctly but 1.3 doesn't work at all, and it's always opened in portrait mode, that means the app failed if user were to lock orientation in anything rather than top-down portrait mode.

As mentioned, the problem i'm seeing is top offset about 20 pixel, if you have NavBar appended, the window would get push down by the amount of offset on top. The fix seems to work for me(so far) but not as elegant if you have sequence of background images in opening the app to loading the data but it will compensate the offset nevertheless.

In app.js, open window in TabBar, then hide the Navbar with win.hideNavBar(), then in that somepage.js, showNavbar() at the end of the loading window and content sequence. The offset is gone if navbar were to append at last.

var tabGroup = Titanium.UI.createTabGroup();
var win = Titanium.UI.createWindow({
win.url = somepage.js
win.hideTabBar(); //hide the tab bar if you don't need it, mine doesn't.

var Tab = Titanium.UI.createTab({window:win,title:"blah"});

Another option is setting delay say 1000-2000ms on tabGroup.open(), allow the screen to switch to correct orientation before open window. But this option is not guaranteed if the timing is wrong and user move the device around before the window open.

I didn't try to create a simple program with no content to test this fix but it's working on the app i'm developing so far. it took me about couple weeks trial and error to find the solution, i hope it's working for you guys that's facing the same problem and want to get the app out asap. Pity the 1.3 is not fixing the issue entirely but worst, failed to load correct orientation.

That said, check your app fully with orientation load (locking) if you were to submit your iPad with 1.3.

— asked May 15th 2010 by Daniel Lim
  • 1.2
  • 1.3
  • bug
  • ipad
  • offset
  • orientation
  • window

1 Answer

  • Something more simpler, hide and then navbar at the end of your loading sequence would reset it!


    — answered May 15th 2010 by Daniel Lim
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.