IdleHandsApps/IHKeyboardAvoiding

Keyboard frame calculations causing issues in IOS 8

Closed this issue · 3 comments

The keyboard frame is also dependent on the rotation of the device in iOS 8. So this is causing the avoided view to be moved incorrectly for iOS 8 devices.

I created my own category on UIScreen for returning the correct height or width depending on the iOS version. Maybe you could use something similar for the keyboard frame....

+ (CGFloat)screenWidth
{
    CGFloat width = [self screenSize].width;

    if (![self isiOSEight])
        if ([self isLandscape])
            width = [UIScreen mainScreen].bounds.size.height;

    return width;
}

+ (CGFloat)screenHeight
{
    CGFloat height = [self screenSize].height;

    if (![self isiOSEight])
        if ([self isLandscape])
            height = [UIScreen mainScreen].bounds.size.width;

    return height;
}

#pragma mark - Helpers

+ (BOOL)isiOSEight
{
    return ([[UIDevice currentDevice].systemVersion floatValue] < 8.0) ? NO : YES;
}

+ (CGSize)screenSize
{
    return [UIScreen mainScreen].bounds.size;
}

+ (BOOL)isLandscape
{
    return UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]);
}

Also one last bit of info. The user info from the notification with the keyboard frame info also changes for iOS 8

Hi Peter,

Ok so Ive redone a lot of the logic to calculate the 'diff'. Your code helped, thanks. Ive just tested on all combinations of iPhone/iPad, iOS7/8, for all four orientations and looks good. Ive just pushed to Github but haven't bumped the Pods version yet - think it needs more testing.

If you have time, a second pair of eyes on these changes would be appreciated

Glad to help.

Had a look and tested it, works fine for iOS 8 & 7! Thanks!