Skip to content

Commit

Permalink
Added Initial support for TopLayoutGuide and BottomLayoutGuide with M…
Browse files Browse the repository at this point in the history
…anual Management. Moved 'UIView+IQKeyboardManagerAdditions' to separate category file

Former-commit-id: b52ea92
  • Loading branch information
hackiftekhar committed Jun 4, 2015
1 parent b05400d commit 486a7ee
Show file tree
Hide file tree
Showing 11 changed files with 177 additions and 30 deletions.
Binary file modified IQKeyBoardManager/.DS_Store
Binary file not shown.
46 changes: 46 additions & 0 deletions IQKeyBoardManager/Categories/IQUITextFieldView+Additions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// IQUITextFieldView+Additions.h
// https://github.com/hackiftekhar/IQKeyboardManager
// Copyright (c) 2013-15 Iftekhar Qurashi.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import <UIKit/UIKit.h>

/**
UIView category for managing UITextField/UITextView
*/

@interface UIView (Additions)

/**
To set customized distance from keyboard for textField/textView. Can't be less than zero
*/
@property(nonatomic, assign) CGFloat keyboardDistanceFromTextField;

@end

///-------------------------------------------
/// @name Custom KeyboardDistanceFromTextField
///-------------------------------------------

/**
Uses default keyboard distance for textField.
*/
extern CGFloat const kIQUseDefaultKeyboardDistance;
54 changes: 54 additions & 0 deletions IQKeyBoardManager/Categories/IQUITextFieldView+Additions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// IQUITextFieldView+Additions.m
// https://github.com/hackiftekhar/IQKeyboardManager
// Copyright (c) 2013-15 Iftekhar Qurashi.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import "IQUITextFieldView+Additions.h"
#import <objc/runtime.h>

@implementation UIView (Additions)

-(void)setKeyboardDistanceFromTextField:(CGFloat)keyboardDistanceFromTextField
{
//Can't be less than zero. Minimum is zero.
keyboardDistanceFromTextField = MAX(keyboardDistanceFromTextField, 0);

objc_setAssociatedObject(self, @selector(keyboardDistanceFromTextField), [NSNumber numberWithFloat:keyboardDistanceFromTextField], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

-(CGFloat)keyboardDistanceFromTextField
{
NSNumber *keyboardDistanceFromTextField = objc_getAssociatedObject(self, @selector(keyboardDistanceFromTextField));

return (keyboardDistanceFromTextField)?[keyboardDistanceFromTextField floatValue]:kIQUseDefaultKeyboardDistance;
}

@end

///------------------------------------
/// @name keyboardDistanceFromTextField
///------------------------------------

/**
Uses default keyboard distance for textField.
*/
CGFloat const kIQUseDefaultKeyboardDistance = CGFLOAT_MAX;

33 changes: 33 additions & 0 deletions IQKeyBoardManager/Categories/IQUIViewController+Additions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// IQUIViewController+Additions.h
// https://github.com/hackiftekhar/IQKeyboardManager
// Copyright (c) 2013-15 Iftekhar Qurashi.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import <UIKit/UIKit.h>

@interface UIViewController (Additions)

/**
Top/Bottom Layout constraint which help library to manage keyboardTextField distance
*/
@property(nonatomic, strong) IBOutlet NSLayoutConstraint *IQLayoutGuideConstraint;

@end
39 changes: 39 additions & 0 deletions IQKeyBoardManager/Categories/IQUIViewController+Additions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// IQUIViewController+Additions.m
// https://github.com/hackiftekhar/IQKeyboardManager
// Copyright (c) 2013-15 Iftekhar Qurashi.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import "IQUIViewController+Additions.h"
#import <objc/runtime.h>

@implementation UIViewController (Additions)

-(void)setIQLayoutGuideConstraint:(NSLayoutConstraint *)IQLayoutGuideConstraint
{
objc_setAssociatedObject(self, @selector(IQLayoutGuideConstraint), IQLayoutGuideConstraint, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

-(NSLayoutConstraint *)IQLayoutGuideConstraint
{
return objc_getAssociatedObject(self, @selector(IQLayoutGuideConstraint));
}

@end
28 changes: 0 additions & 28 deletions IQKeyBoardManager/IQKeyboardManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,31 +295,3 @@ extern NSInteger const kIQPreviousNextButtonToolbarTag;

@end



///-------------------------------------------
/// @name Custom KeyboardDistanceFromTextField
///-------------------------------------------

/**
Uses default keyboard distance for textField.
*/
extern CGFloat const kIQUseDefaultKeyboardDistance;

/**
UIView category for IQKeyboardManager
*/
@interface UIView (IQKeyboardManagerAdditions)

/**
To set customized distance from keyboard for textField/textView. Can't be less than zero
*/
//#if TARGET_INTERFACE_BUILDER
//@property(nonatomic, assign) IBInspectable CGFloat keyboardDistanceFromTextField;
//#else
@property(nonatomic, assign) CGFloat keyboardDistanceFromTextField;
//#endif

@end


2 changes: 1 addition & 1 deletion IQKeyBoardManager/IQKeyboardManager.m.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
75c7be7ceb12526c9e315a339aa857e977ea869a
54f99e0a0602d71225a6fb3526d0af9800d1149d
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f6bc932d93abc06c16249b9d1b1716d2ffc4ae0b
b8edd0e70f7d567c565d1d277920d03cbad35469
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0648cc43c0204888d34815fb71a37289b7c0ebd6
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0065327ad4c2872c16127587c6395fbbd75bca17
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ae7288e6f66b0d78d2fc7fa4b158822db4956ba2

0 comments on commit 486a7ee

Please sign in to comment.