Closed jcmartinac closed 6 years ago
Hey!
The problem is that up to a certain iOS (forgot which), that logic worked, because the window width was the device's height (and vice-versa for height) in landscape. Sadly, I can't remember when this was changed/fixed and I don't have a way to test the change on iOS 7.
I can not test on iOS7 neither, so tell me if there is anything more I can do to improve the pull request. Also I have found another issue related to device orientation when the navigation bar is shown. When rotation detected I try to redraw the navigation bar because in landscape we hide the status bar. But the statusBarFrameOrOrientationChanged method does not return the status bar frame correctly just when executed and I would like to use viewWillTransitionToSize:withTransitionCoordinator: that executes a block when completes animation, but is never called
Hmm, taking into account the code from statusBarFrameOrOrientationChanged:
, it seems that we need to check if it's iOS 8 or higher.
So we could do it like this:
if (LTHiOS8 || UIInterfaceOrientationIsPortrait(orientation)) {
return [UIApplication sharedApplication].statusBarFrame.size.height;
}
else {
return [UIApplication sharedApplication].statusBarFrame.size.width;
}
And while we're at this, would you be willing to update statusBarFrameOrOrientationChanged:
in the same manner, please? Just so it's done in the same commit.
if (LTHiOS8 || UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation)) {
_animatingView.frame = LTHMainWindow.bounds;
}
else {
_animatingView.frame = CGRectMake(0, 0, LTHMainWindow.frame.size.height, LTHMainWindow.frame.size.width);
}
As for the viewWillTransitionToSize:withTransitionCoordinator:
call, you need to add [LTHPasscodeViewController sharedUser]
as a child view controller wherever you're showing it, after you called the showLockScreen
method, for example:
- (void)showLockViewForTestingPasscode {
[[LTHPasscodeViewController sharedUser] showLockScreenWithAnimation:YES
withLogout:YES
andLogoutTitle:@"AAA"];
[self addChildViewController:[LTHPasscodeViewController sharedUser]];
}
Don't forget to also remove it when you're done with it, otherwise you'll get an exception when you do it the second time.
But viewWillTransitionToSize:withTransitionCoordinator:
was introduced in iOS 8, so willRotateToInterfaceOrientation:duration:
would have to be implemented as well, for iOS 6 and 7; preferably both calling the same private method that does the actual redraw.
I have been testing your changes and don't solve the patch view getting wrong height, so the digits can't be seen...
Which part doesn't work?
@jcmartinac Any updates on this?
Hi! Checking the behavior a bit more detailed, I have found that when the LTHPasscodeViewController is shown with the navigation bar in landscape mode, the status bar height is returned as its width, do not know why, maybe old iOS versions... but in our app, that allows screen rotation, if you start the app in landscape, the patch view created in the previous pull request gets a height of the status bar width (this is screen width), so it is a withe view filling all the screen.