Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIViewController's view has weird 20px y margin

I am adding a UIViewController's view to another UIViewController's views (using the new UIViewController Containment APIs). After adding the vc's view as another's subivew, there's a weird 20px margin from the top.

I logged the view and it's from origin was 0,0. However, I when I log the view's superview, it's:

<UIViewControllerWrapperView: 0x6c5e2c0; frame = (0 20; 703 748); autoresize = RM+BM; layer = <CALayer: 0x6c54190>>

I can obviously change it's frame to 0,0. But i am wondering what's the right way to do this? Why is the vc's view's superview's frame 0,20? Should I modify this or is there a better way to go around this weird margin?

Thanks

like image 968
0xSina Avatar asked Jun 28 '12 20:06

0xSina


1 Answers

To fix this problem just check the box "Wants Full Screen" on the storyboard.

The problem appears because the ParentViewController is showing the navigation bar.

As apple documentation said :

If your app displays the status bar, the view shrinks so that it does not underlap the status bar. After all, if the status bar is opaque, there is no way to see or interact with the content lying underneath it. However, if your app displays a translucent status bar, you can set the value of your view controller’s wantsFullScreenLayout property to YES to allow your view to be displayed full screen. The status bar is drawn over the top of the view.

like image 134
ant_one Avatar answered Oct 18 '22 19:10

ant_one