Reputation: 893
I have a viewcontroller(Nib) that is invoked from two different places. When I invoke it from one place, all looks fine but from the other it always seems to have a 20px(looks like enough for the status bar) offset up top..
If I rotate the device this goes away and it looks OK..I've been troubleshooting this since yesterday with no luck - As far as I can tell I'm not doing anything different when I load the screen..
I'm not really sure what code to paste, as from both places they are being called in the same way, I'm looking for any ideas - even if it's not an answer as I seem to be out of ideas.
Screenshot,
Upvotes: 0
Views: 134
Reputation: 4198
I hope that these questions will help us and you to pinpoint the problem:
Are you invoking the VC using Interface builder or programmatically?
Have you added any or none constraints?
My best guess would be that you try to load the VC from:
- (void)viewWillLayoutSubviews
rather then
- (void)viewDidLoad
The reason for this suggestion is that the screen bounds are not properly loaded in viewDidLoad which you can check by printing self.view.bounds.width
& self.view.bounds.height
. In viewDidLoad they are not set correctly. This can lead to many later problems. This is just a wild guess.
Hope it helps.
Upvotes: 0
Reputation: 581
Did you try setting edgesForExtendedLayout
in viewDidLoad
?
if ( IS_OS_7_OR_LATER && [self respondsToSelector:@selector(edgesForExtendedLayout)] ) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
EDIT: here is the iOS 7 Transition Guide from Apple if you want more info on how this is fixed for iOS 7
Upvotes: 1