0

Am getting a white space at top in all containers. if I do a model transition that white space is clearly visible on top of all navigation controllers.

that space is around 20px.

How to remove this white space..??

Any suggestion ???

nik
  • 2,289
  • 6
  • 37
  • 60
  • I had this problem, check this question: http://stackoverflow.com/questions/1054539/not-sure-why-uiview-is-being-nudged-up-by-around-10px – TomCobo May 09 '13 at 09:11
  • Thanks for response but my problem here is different – nik May 09 '13 at 09:19
  • you need to provide more details, pictures of what it looks like before the space appears and after. Code of how your doing it and any information on anything fancy or extra your adding in beyond just calling present modal view. E.g. dynamically creating subviews to draw the screen etc. – Simon McLoughlin May 09 '13 at 09:41

1 Answers1

0

You didn't really give us enough details in your question, but the most likely cause for your problem is that you are instantiating the subviews programmatically for your viewcontrollers using the viewcontroller's view frame rather than the bounds.

If in your viewDidLoad method you do something like:

- (void)viewDidLoad
{
    [super viewDidLoad];
    MyView* myView = [[MyView alloc] initWithFrame:self.view.frame];
    [self.view addSubview:myView];
}

then your view will be initialized with an offset of 20px, because your self.view.frame's origin is (0, 20), in order to not overlap with the navigation bar. If you then set your subview's frame with that same origin, it means that the view's origin will be 20 px further translated down (it's not really pixels but points, as the value stays the same whether it's a retina display or not, but whatever).

So, if you want to add a subview that is the size of the view controller's view that is presenting it, then you should always initialize it with:

    MyView* myView = [[MyView alloc] initWithFrame:self.view.bounds];

I hope this helps, you didn't give us much to work with in your question, in the future try to give us (many many) more details about what it is that you do, both in the code and in the storyboard.

micantox
  • 5,446
  • 2
  • 23
  • 27