Reputation: 1287
I have have a View containing:
MKMapView
, to display some items on a mapUITableView
embedded in a UIView
, to display the items in a listThe user must be able to display the map or the list, by moving a separator.
This works well, but I encounter an issue after the user rotates the screen: in this case, the list is no longer correctly displayed.
The list's position UIView
is setted by specifying it's top margin constraint: the first time I know the status bar height (with UIApplication.SharedApplication.StatusBarFrame.Height
).
But after the rotation, I need to recalculate this constraint. For this, I try to recalculate the constraints in ViewWillTransitionToSize()
.
My problem is that I don't get the expected value during the call to ViewWillTransitionToSize()
: the "old" value of StatusBarFrame.Height
is setted.
I also try to get the statusbar status
with UIApplication.SharedApplication.StatusBarHidden
but the problem is the same.
Is there another way allowing me to get the correct statusbar height during the rotation?
Upvotes: 0
Views: 184
Reputation: 1287
I've tested the statusbar status at the wrong place:
public override void ViewWillTransitionToSize(CoreGraphics.CGSize toSize, IUIViewControllerTransitionCoordinator coordinator)
{
coordinator.AnimateAlongsideTransition((IUIViewControllerTransitionCoordinatorContext obj) => {
// Define any animations you want to perform (equivilent to willRotateToInterfaceOrientation)
// StatusBar status and height is not yet updated
}, (IUIViewControllerTransitionCoordinatorContext obj) => {
// Completition executed after transistion finishes (equivilent to didRotateFromInterfaceOrientation)
// StatusBar status and height is well updated
});
base.ViewWillTransitionToSize(toSize, coordinator);
}
If the test is dont correctly, this works fine.
Upvotes: 0