diff --git a/IQKeyBoardManager/Categories/IQNSArray+Sort.m b/IQKeyBoardManager/Categories/IQNSArray+Sort.m index 700de9b..3898efb 100644 --- a/IQKeyBoardManager/Categories/IQNSArray+Sort.m +++ b/IQKeyBoardManager/Categories/IQNSArray+Sort.m @@ -22,14 +22,10 @@ // THE SOFTWARE. #import "IQNSArray+Sort.h" -#import "IQKeyboardManagerConstantsInternal.h" #import "IQUIView+Hierarchy.h" #import -IQ_LoadCategory(IQNSArraySort) - - @implementation NSArray (IQ_NSArray_Sort) - (NSArray*)sortedArrayByTag diff --git a/IQKeyBoardManager/Categories/IQUIView+Hierarchy.m b/IQKeyBoardManager/Categories/IQUIView+Hierarchy.m index 7e42673..507f2b5 100644 --- a/IQKeyBoardManager/Categories/IQUIView+Hierarchy.m +++ b/IQKeyBoardManager/Categories/IQUIView+Hierarchy.m @@ -22,7 +22,6 @@ // THE SOFTWARE. #import "IQUIView+Hierarchy.h" -#import "IQKeyboardManagerConstantsInternal.h" #import #import @@ -34,10 +33,6 @@ #import - -IQ_LoadCategory(IQUIViewHierarchy) - - @implementation UIView (IQ_UIView_Hierarchy) //Special textFields,textViews,scrollViews diff --git a/IQKeyBoardManager/Categories/IQUIWindow+Hierarchy.m b/IQKeyBoardManager/Categories/IQUIWindow+Hierarchy.m index 0f7f995..b9d2f93 100644 --- a/IQKeyBoardManager/Categories/IQUIWindow+Hierarchy.m +++ b/IQKeyBoardManager/Categories/IQUIWindow+Hierarchy.m @@ -22,13 +22,8 @@ // THE SOFTWARE. #import "IQUIWindow+Hierarchy.h" - #import -#import "IQKeyboardManagerConstantsInternal.h" -IQ_LoadCategory(IQUIWindowHierarchy) - - @implementation UIWindow (IQ_UIWindow_Hierarchy) - (UIViewController*) topMostController diff --git a/IQKeyBoardManager/Constants/IQKeyboardManagerConstantsInternal.h b/IQKeyBoardManager/Constants/IQKeyboardManagerConstantsInternal.h index c8d56b8..d75a3ed 100644 --- a/IQKeyBoardManager/Constants/IQKeyboardManagerConstantsInternal.h +++ b/IQKeyBoardManager/Constants/IQKeyboardManagerConstantsInternal.h @@ -27,24 +27,19 @@ //Xcode 4.6 or less compilation check #ifdef NSFoundationVersionNumber_iOS_6_1 #define IQ_IS_IOS7_OR_GREATER (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) + #define IQ_IS_XCODE_5_1_OR_GREATER 1 #else #define IQ_IS_IOS7_OR_GREATER NO + #define IQ_IS_XCODE_5_1_OR_GREATER 0 #endif //Xcode 5.1 or less compilation check #ifdef NSFoundationVersionNumber_iOS_7_1 #define IQ_IS_IOS8_OR_GREATER (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1) + #define IQ_IS_XCODE_6_0_OR_GREATER 1 #else #define IQ_IS_IOS8_OR_GREATER NO + #define IQ_IS_XCODE_6_0_OR_GREATER 0 #endif - -/** https://github.com/kif-framework/KIF/blob/master/Additions/LoadableCategory.h - - @discussion To load categories in the current file loadable without using "-load-all" flag. When we try to create framework or library the compilers skips linking files that contain only categories. So use this macro to add a dummy class, which causes the linker to add the file. You will also need to add "-ObjC" to the "Other Linker Flags" build setting in any project that uses the framework. - - @param UNIQUE_NAME A globally unique name. - */ -#define IQ_LoadCategory(UNIQUE_NAME) @interface FORCELOAD_##UNIQUE_NAME :NSObject @end @implementation FORCELOAD_##UNIQUE_NAME @end - #endif diff --git a/IQKeyBoardManager/IQTextView/IQTextView.m b/IQKeyBoardManager/IQTextView/IQTextView.m index 6f63754..fe4da81 100644 --- a/IQKeyBoardManager/IQTextView/IQTextView.m +++ b/IQKeyBoardManager/IQTextView/IQTextView.m @@ -24,6 +24,7 @@ #import "IQTextView.h" #import +#import @implementation IQTextView { @@ -32,6 +33,31 @@ @synthesize placeholder = _placeholder; +-(void)initialize +{ + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshPlaceholder) name:UITextViewTextDidChangeNotification object:self]; +} + +-(void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +- (instancetype)init +{ + self = [super init]; + if (self) { + [self initialize]; + } + return self; +} + +-(void)awakeFromNib +{ + [super awakeFromNib]; + [self initialize]; +} + -(void)refreshPlaceholder { if([[self text] length]) @@ -42,18 +68,26 @@ { [placeHolderLabel setAlpha:1]; } -} - -- (void)setText:(NSString *)text -{ - [super setText:text]; - [self refreshPlaceholder]; + + [self setNeedsLayout]; + [self layoutIfNeeded]; } -(void)setFont:(UIFont *)font { [super setFont:font]; placeHolderLabel.font = self.font; + + [self setNeedsLayout]; + [self layoutIfNeeded]; +} + +-(void)layoutSubviews +{ + [super layoutSubviews]; + + [placeHolderLabel sizeToFit]; + placeHolderLabel.frame = CGRectMake(8, 8, CGRectGetWidth(self.frame)-16, CGRectGetHeight(placeHolderLabel.frame)); } -(void)setPlaceholder:(NSString *)placeholder @@ -62,7 +96,7 @@ if ( placeHolderLabel == nil ) { - placeHolderLabel = [[UILabel alloc] initWithFrame:CGRectInset(self.bounds, 8, 8)]; + placeHolderLabel = [[UILabel alloc] init]; placeHolderLabel.autoresizingMask = (UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight); placeHolderLabel.lineBreakMode = NSLineBreakByWordWrapping; placeHolderLabel.numberOfLines = 0; @@ -77,11 +111,4 @@ [self refreshPlaceholder]; } -//When any text changes on textField, the delegate getter is called. At this time we refresh the textView's placeholder --(id)delegate -{ - [self refreshPlaceholder]; - return [super delegate]; -} - @end diff --git a/IQKeyBoardManager/IQToolbar/IQUIView+IQKeyboardToolbar.m b/IQKeyBoardManager/IQToolbar/IQUIView+IQKeyboardToolbar.m index f6b967f..b76ea60 100644 --- a/IQKeyBoardManager/IQToolbar/IQUIView+IQKeyboardToolbar.m +++ b/IQKeyBoardManager/IQToolbar/IQUIView+IQKeyboardToolbar.m @@ -33,8 +33,6 @@ #import #import -IQ_LoadCategory(IQUIViewToolbar) - /*UIKeyboardToolbar Category implementation*/ @implementation UIView (IQToolbarAddition) @@ -442,6 +440,9 @@ IQ_LoadCategory(IQUIViewToolbar) UIImage *imageLeftArrow; UIImage *imageRightArrow; + //Xcode Compilation check +#if IQ_IS_XCODE_6_0_OR_GREATER + if (IQ_IS_IOS8_OR_GREATER) { // Get the top level "bundle" which may actually be the framework @@ -458,6 +459,7 @@ IQ_LoadCategory(IQUIViewToolbar) imageRightArrow = [UIImage imageNamed:@"IQButtonBarArrowRight" inBundle:resourcesBundle compatibleWithTraitCollection:nil]; } else +#endif { imageLeftArrow = [UIImage imageNamed:@"IQKeyboardManager.bundle/IQButtonBarArrowLeft"]; imageRightArrow = [UIImage imageNamed:@"IQKeyboardManager.bundle/IQButtonBarArrowRight"]; @@ -564,6 +566,9 @@ IQ_LoadCategory(IQUIViewToolbar) UIImage *imageLeftArrow; UIImage *imageRightArrow; + //Xcode Compilation check +#if IQ_IS_XCODE_6_0_OR_GREATER + if (IQ_IS_IOS8_OR_GREATER) { // Get the top level "bundle" which may actually be the framework @@ -580,6 +585,7 @@ IQ_LoadCategory(IQUIViewToolbar) imageRightArrow = [UIImage imageNamed:@"IQButtonBarArrowRight" inBundle:resourcesBundle compatibleWithTraitCollection:nil]; } else +#endif { imageLeftArrow = [UIImage imageNamed:@"IQKeyboardManager.bundle/IQButtonBarArrowLeft"]; imageRightArrow = [UIImage imageNamed:@"IQKeyboardManager.bundle/IQButtonBarArrowRight"]; diff --git a/KeyboardTextFieldDemo/.DS_Store b/KeyboardTextFieldDemo/.DS_Store index 38c359a..bc69393 100644 Binary files a/KeyboardTextFieldDemo/.DS_Store and b/KeyboardTextFieldDemo/.DS_Store differ diff --git a/KeyboardTextFieldDemo/IQKeyboardManager.xcodeproj/project.xcworkspace/xcuserdata/iftekhar.xcuserdatad/UserInterfaceState.xcuserstate b/KeyboardTextFieldDemo/IQKeyboardManager.xcodeproj/project.xcworkspace/xcuserdata/iftekhar.xcuserdatad/UserInterfaceState.xcuserstate index 2fead71..389c726 100644 Binary files a/KeyboardTextFieldDemo/IQKeyboardManager.xcodeproj/project.xcworkspace/xcuserdata/iftekhar.xcuserdatad/UserInterfaceState.xcuserstate and b/KeyboardTextFieldDemo/IQKeyboardManager.xcodeproj/project.xcworkspace/xcuserdata/iftekhar.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/KeyboardTextFieldDemo/IQKeyboardManager.xcodeproj/xcuserdata/iftekhar.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/KeyboardTextFieldDemo/IQKeyboardManager.xcodeproj/xcuserdata/iftekhar.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 8f94031..aa357d9 100644 --- a/KeyboardTextFieldDemo/IQKeyboardManager.xcodeproj/xcuserdata/iftekhar.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/KeyboardTextFieldDemo/IQKeyboardManager.xcodeproj/xcuserdata/iftekhar.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -13,5 +13,21 @@ stopOnStyle = "0"> + + + +