From 39bddfd08b1e9c1d466e0e035db78759e51478ed Mon Sep 17 00:00:00 2001 From: Fraser Date: Fri, 22 Aug 2014 14:51:24 +1200 Subject: [PATCH] Fixed bug where unbackgrounding would over avoid --- .gitignore | 2 ++ Classes/IHKeyboardAvoiding.m | 10 ++++++++++ Example/IHKeyboardAvoiding-Info.plist | 4 ++-- IHKeyboardAvoiding.podspec | 2 +- IHKeyboardAvoiding.xcodeproj/project.pbxproj | 4 ++++ 5 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d7c7ab --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +*.xcuserstate diff --git a/Classes/IHKeyboardAvoiding.m b/Classes/IHKeyboardAvoiding.m index 464c449..153123c 100755 --- a/Classes/IHKeyboardAvoiding.m +++ b/Classes/IHKeyboardAvoiding.m @@ -247,6 +247,7 @@ + (void)init { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ // make sure we only add this once + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didChange:) name:UIKeyboardWillChangeFrameNotification object:nil]; _targetViews = [[NSMutableArray alloc] init]; _updatedConstraints = [[NSMutableArray alloc] init]; @@ -254,4 +255,13 @@ + (void)init { }); } +#pragma mark - + ++ (void)applicationDidEnterBackground:(NSNotification *)notification +{ + // Autolayout is reset when app goes into background, so we need to dismiss the keyboard too + UIWindow *window = [UIApplication sharedApplication].windows[0]; + [window.rootViewController.view endEditing:YES]; +} + @end diff --git a/Example/IHKeyboardAvoiding-Info.plist b/Example/IHKeyboardAvoiding-Info.plist index 5094b02..65efdfd 100644 --- a/Example/IHKeyboardAvoiding-Info.plist +++ b/Example/IHKeyboardAvoiding-Info.plist @@ -17,11 +17,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0 + 1.0.1 CFBundleSignature ???? CFBundleVersion - 1.0 + 1.0.1 LSRequiresIPhoneOS UIRequiredDeviceCapabilities diff --git a/IHKeyboardAvoiding.podspec b/IHKeyboardAvoiding.podspec index d9de5ad..852985a 100644 --- a/IHKeyboardAvoiding.podspec +++ b/IHKeyboardAvoiding.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'IHKeyboardAvoiding' - s.version = '1.0.0' + s.version = '1.0.1' s.summary = 'IHKeyboardAvoiding is an elegant solution for keeping any UIView visible when the keyboard is being shown' s.homepage = 'https://github.com/IdleHandsApps/IHKeyboardAvoiding/' s.description = <<-DESC diff --git a/IHKeyboardAvoiding.xcodeproj/project.pbxproj b/IHKeyboardAvoiding.xcodeproj/project.pbxproj index 83830fc..002f0fa 100644 --- a/IHKeyboardAvoiding.xcodeproj/project.pbxproj +++ b/IHKeyboardAvoiding.xcodeproj/project.pbxproj @@ -22,6 +22,7 @@ 1AFC71BB192382BB003B85FB /* IHViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AFC71AF192382BB003B85FB /* IHViewController.m */; }; 1AFC71BC192382BB003B85FB /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AFC71B0192382BB003B85FB /* main.m */; }; 4C0593D91932D1D800BFD714 /* IHKeyboardAvoiding.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C0593D81932D1D800BFD714 /* IHKeyboardAvoiding.m */; }; + 4C58B40C19A6E41B00AF3484 /* IHKeyboardAvoiding.podspec in Resources */ = {isa = PBXBuildFile; fileRef = 4C58B40B19A6E41B00AF3484 /* IHKeyboardAvoiding.podspec */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -46,6 +47,7 @@ 4C0593D81932D1D800BFD714 /* IHKeyboardAvoiding.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IHKeyboardAvoiding.m; sourceTree = ""; }; 4C0593DA1932D34900BFD714 /* IHKeyboardAvoiding-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "IHKeyboardAvoiding-Info.plist"; sourceTree = ""; }; 4C0593DB1932D34900BFD714 /* IHKeyboardAvoiding-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "IHKeyboardAvoiding-Prefix.pch"; sourceTree = ""; }; + 4C58B40B19A6E41B00AF3484 /* IHKeyboardAvoiding.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = IHKeyboardAvoiding.podspec; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -94,6 +96,7 @@ 1AFC719519238202003B85FB /* Supporting Files */ = { isa = PBXGroup; children = ( + 4C58B40B19A6E41B00AF3484 /* IHKeyboardAvoiding.podspec */, 1AFC71A8192382BB003B85FB /* InfoPlist.strings */, 4C0593DA1932D34900BFD714 /* IHKeyboardAvoiding-Info.plist */, 4C0593DB1932D34900BFD714 /* IHKeyboardAvoiding-Prefix.pch */, @@ -192,6 +195,7 @@ 1AFC71B6192382BB003B85FB /* IHViewController_iPad.xib in Resources */, 1AFC71B5192382BB003B85FB /* diamond_upholstery@2x.png in Resources */, 1AFC71B4192382BB003B85FB /* diamond_upholstery.png in Resources */, + 4C58B40C19A6E41B00AF3484 /* IHKeyboardAvoiding.podspec in Resources */, ); runOnlyForDeploymentPostprocessing = 0; };