Skip to content

Commit

Permalink
Fixed bug where unbackgrounding would over avoid
Browse files Browse the repository at this point in the history
  • Loading branch information
fraserscottmorrison committed Aug 22, 2014
1 parent 249c7fd commit 39bddfd
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

*.xcuserstate
10 changes: 10 additions & 0 deletions Classes/IHKeyboardAvoiding.m
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,21 @@ + (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];
_updatedConstraintConstants = [[NSMutableArray alloc] 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
4 changes: 2 additions & 2 deletions Example/IHKeyboardAvoiding-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<string>1.0.1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
Expand Down
2 changes: 1 addition & 1 deletion IHKeyboardAvoiding.podspec
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions IHKeyboardAvoiding.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -46,6 +47,7 @@
4C0593D81932D1D800BFD714 /* IHKeyboardAvoiding.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IHKeyboardAvoiding.m; sourceTree = "<group>"; };
4C0593DA1932D34900BFD714 /* IHKeyboardAvoiding-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "IHKeyboardAvoiding-Info.plist"; sourceTree = "<group>"; };
4C0593DB1932D34900BFD714 /* IHKeyboardAvoiding-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "IHKeyboardAvoiding-Prefix.pch"; sourceTree = "<group>"; };
4C58B40B19A6E41B00AF3484 /* IHKeyboardAvoiding.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = IHKeyboardAvoiding.podspec; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -94,6 +96,7 @@
1AFC719519238202003B85FB /* Supporting Files */ = {
isa = PBXGroup;
children = (
4C58B40B19A6E41B00AF3484 /* IHKeyboardAvoiding.podspec */,
1AFC71A8192382BB003B85FB /* InfoPlist.strings */,
4C0593DA1932D34900BFD714 /* IHKeyboardAvoiding-Info.plist */,
4C0593DB1932D34900BFD714 /* IHKeyboardAvoiding-Prefix.pch */,
Expand Down Expand Up @@ -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;
};
Expand Down

0 comments on commit 39bddfd

Please sign in to comment.