views:

839

answers:

5

I have a fullscreen view (768x1004), when I add a fullscreen subview to this view, it is incorrectly positioned by the height of the status bar (20 pixels). So the view will be clipped by 20 pixels at the top. I can't figure out why this is happening. The only way I can fix it is to set the origin to CGPointMake(0, 20) in viewDidLoad.

I have the main xib which contains a view controller (the MainViewController) and a view, the MainView. fullscreen mode is not on. Yet it is still incorrectly positioned by the amount of the status bar. If I just move it down 20 pixels everything works fine, so it isn't that big of a deal, but it is annoying why such a thing would be happening.

A: 

Your "full screen" view at (768x1004) isn't correct (or is it a type-o?) it should be (768x1024). That may account for your 20 pixel issue.

jamone
A: 

Make sure you have resize subivews enabled and that you anchor the subview to the bottom of the parent instead of the top. Easily done in IB, by deselecting the top sticky and enabling the bottom one.

willcodejavaforfood
That didn't work.
DevDevDev
+1  A: 

If you set the wantsFullScreenLayout property in UIViewController, it means you want the full screen which is 1024x768, not 1004x768. Full screen means including the status bar. You can hide the status bar and the area under it will be displayed. Make sure you have that property turned off if you want your content to be properly sized with a status bar.

lucius
That didn't work
DevDevDev
Maybe it's a bug in the OS then. I've seen a bug where I'm doing full screen layout and if the device rotation changes while another view is being presented modally, going back to the original view causes the subviews to be incorrectly positioned.
lucius
What didn't work, hiding the status bar? Or it hid, but your subview is still incorrectly positioned?
progrmr
I don't want to hide the status bar, I have a 768x1004 view, which is the mainView loaded from a xib. It is positioned at the iPad's origin (0,0) in the 768x1024 view. Rather than at (0,20) as it were.
DevDevDev
I believe you need to set wantsFullScreenLayout before your view loads. So if it's your root view controller, set it in the app delegate before you add the view to main window.
skantner
A: 

I have had the same problem on an iPhone project. It was somehow related to an Interface builder bug that scrambled my view xib. I simply restored it from my version control system, reapplied my changes. Everything went Ok the second time, no problems with a position offset.

If that's not an option, try looking at your xib manually (it's an xml file) and check wether you can see something obviously wrong.

Keep in mind that the iPad SDK is still beta.

Johannes Rudolph
A: 

Same issue here with a modal view controller. It all seems like "wantsFullScreen" View Controller property is always on on the iPad.

Any success finding what the issue is ?

Ben G