★ TouchArcade needs your help. Click here to support us on Patreon.

Notifications tab on the side of the screen for a portrait mode game

06-08-2012, 04:56 AM
#1
Joined: Apr 2012
Posts: 57
Notifications tab on the side of the screen for a portrait mode game

Hi,

I've just noticed something weird that I might use to my advantage in the game I'm currently working on...

I use return (interfaceOrientation == UIInterfaceOrientationPortrait); in the shouldAutorotateToInterfaceOrientation: method from my main viewcontroller to force the screen to lock to portrait mode.

When I start my game with the iPad already in portrait mode, the notifications tab appears on the top of the screen, where it can get in the way of the player playing the game in that side of the screen, but when I start the game in landscape mode, it stays on the long side of the screen, where it can't bother anyone.

I thought when I'd lock the screen to portrait mode it would affect the whole system, but it seems to affect only my application. It'd be nice if I could first make sure the screen is set to landscape mode for the whole system and then lock it to portrait mode for my app, this way the notifications tab would always stay on one side of the screen...

Any help would be appreciated...

- makaGeorge (www.makasoft.net)
06-08-2012, 12:00 PM
#2
Joined: May 2009
Location: UK
Posts: 741
you should really let the OS know the orientation. There is an undocumented (as far as I can tell) trick that Apple use to get greater accuracy. Apple tweak the touch coordinate to be several pixels up from where it's actually touched.

If you don't tell the OS you will find the touch accuracy is out in some direction or other depending on the real life orientation.

It's easy to prove it does this. Take a drawing app (sketchbook pro for example) and put it flat on a table. Draw a horizontal line and see what part of your finger the line comes from. Now spin the device 180 degrees (which of course turns it upsidedown without changing gravity, it's on a flat surface), now try drawing a line and it comes from a point clearly lower on your finger.

All iOS apps use this offset, everyone is used to it, you can't fight it, your touch accuracy will feel wrong if you don't tell the OS the orientation.

-=< Fat Owl With A Jetpack >=-
-=< Topia World Builder >=-
-=< Twitter >=-
-=< Blog >=-
06-08-2012, 09:16 PM
#3
Joined: Apr 2012
Posts: 57
thanks. I didn't think about that, but it's not much of an issue in my case as my game uses large control areas instead of visible controls...

But, let me see if I understand... Do you mean that the way I'm locking the screen to portrait mode is not the correct way to do it? Should I do something else to inform the system about it?

- makaGeorge (www.makasoft.net)
06-10-2012, 04:18 AM
#4
Joined: May 2009
Location: UK
Posts: 741
It would be much easier to answer this from my computer so I could refer to source code. There is a function called something like SetStatusBarOrientation or similar. My accelerometer code calls this when it detects a reorientation. I think my code is a little retro, there are newer classes in newer Apple code samples that handle this stuff for you more automatically but under the hood they must be calling the same thing.

The point is, I thought I could get away without telling the system the orientation as my code handled all of it until I noticed this offset thing. You are correct to point out that this might not be an issue if you only have a few big buttons.
06-12-2012, 04:24 AM
#5
Joined: Apr 2012
Posts: 57
Thanks! Just gave it a try and it works...

I call it just before the game starts to make sure the notifications tab is not in the way for the player playing on the top of the screen. Exiting to the system can modify this again, so I need to set it back when the game returns to the front...

- makaGeorge (www.makasoft.net)