Reputation: 6213
I have a UIViewController
with no status bar, and it launches a second UIViewController
that has a status bar.
If the extended status bar is active, both views show correctly, but when I exit the second view and go back to the first, I see a 20pt black bar at the top and the whole view is pushed down, obscuring the bottom.
I tried resetting the frame to origin 0,0 in viewDidAppear
but it has no effect.
Why is the view pushed down and how can I fix it?
- (BOOL)prefersStatusBarHidden {
return YES;
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.view.frame = CGRectMake(0, 0, self.width, self.height);
self.view.backgroundColor = [UIColor redColor];
}
- (void)openShare {
Share *share = [[Share alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:share];
nav.modalTransitionStyle = UIModalPresentationPopover;
[self presentViewController:nav animated:YES completion:nil];
}
top of the view before openShare
is called:
top of the view after Share
is presented and dismissed:
Upvotes: 3
Views: 286
Reputation: 6112
Yesterday I had the exact same problem in my app.
I made two things that solve the problem.
Top Space to: Top Layout Guide
constraint with a constant of 20 (same as status bar height) on my navigationBar
I added this in the controllers that have the issue ([self.view layoutSubviews]
)
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self.view layoutSubviews];
}
Upvotes: 0