Open gmondada opened 8 years ago
2 years past, the bug still there on iOS 10
First on Portrait view ( Fine )
Rotate to landscape
Rotate back to portrait
No one want to solve this bug?
Did you got soultion for this i am facing same issue
@rayalarajee Try to look and solve as soon as possible time.
Could you please let me know if you found soultion @kemalserkan @timeflying
@rayalarajee @timeflying Hey there! I Don't know why but when orientation changes screen size remains previous.
Here is the solution or fix:
- (void)changeOrientationForIOS8: (NSNotification *)notification {
CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
UIDevice *device = notification.object;
CGFloat minDim = MIN(screenWidth, screenHeight);
CGFloat maxDim = MAX(screenWidth, screenHeight);
switch (device.orientation)
{
case UIDeviceOrientationPortrait:
screenWidth = minDim;
screenHeight = maxDim;
break;
case UIDeviceOrientationLandscapeLeft:
screenWidth = maxDim;
screenHeight = minDim;
break;
case UIDeviceOrientationLandscapeRight:
screenWidth = maxDim;
screenHeight = minDim;
break;
case UIDeviceOrientationPortraitUpsideDown:
screenWidth = minDim;
screenHeight = maxDim;
break;
default:
break;
}
[UIView animateWithDuration:0.2f delay:0.0 options:UIViewAnimationOptionTransitionNone
animations:^{
CGSize dialogSize = [self countDialogSize];
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
self.frame = CGRectMake(0, 0, screenWidth, screenHeight);
self->dialogView.frame = CGRectMake((screenWidth - dialogSize.width) / 2, (screenHeight - keyboardSize.height - dialogSize.height) / 2, dialogSize.width, dialogSize.height);
}
completion:nil
];
}
and don' forget to pass [UIDevice currentDevice] as object to notification in init:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange:) name:UIDeviceOrientationDidChangeNotification object:[UIDevice currentDevice]];
If you take the CustomIOSAlertView demo app, add a launch screen storyboard and run in the iPad Air iOS9 simulator, device rotations are not working anymore. The problem comes from [UIScreen mainScreen].bounds.size returning the size of the screen before the orientation change. This is a very strange problem not happing, for instance, on iPad 2 iOS8.4 and iPhone 5 iOS9.0.2. Seen on the simulator but also on a real iPad Air 1. It doesn't depend on the Deployment Target. Tested on Xcode 7.0.1.