This commit is contained in:
hackiftekhar
2015-04-19 22:55:39 +05:30
43 changed files with 1096 additions and 764 deletions

View File

@@ -24,23 +24,21 @@
#import <Foundation/NSArray.h>
/**
@category NSArray (IQ_NSArray_Sort)
@abstract UIView.subviews sorting category.
UIView.subviews sorting category.
*/
@interface NSArray (IQ_NSArray_Sort)
///--------------
/// @name Sorting
///--------------
/**
@method sortedArrayByTag
@return Returns the array by sorting the UIView's by their tag property.
Returns the array by sorting the UIView's by their tag property.
*/
- (NSArray*)sortedArrayByTag;
/**
@method sortedArrayByTag
@return Returns the array by sorting the UIView's by their tag property.
Returns the array by sorting the UIView's by their tag property.
*/
- (NSArray*)sortedArrayByPosition;

View File

@@ -49,14 +49,19 @@
{
return [self sortedArrayUsingComparator:^NSComparisonResult(UIView *view1, UIView *view2) {
if (view1.IQ_y < view2.IQ_y) return NSOrderedAscending;
CGFloat x1 = CGRectGetMinX(view1.frame);
CGFloat y1 = CGRectGetMinY(view1.frame);
CGFloat x2 = CGRectGetMinX(view2.frame);
CGFloat y2 = CGRectGetMinY(view2.frame);
else if (view1.IQ_y > view2.IQ_y) return NSOrderedDescending;
if (y1 < y2) return NSOrderedAscending;
else if (y1 > y2) return NSOrderedDescending;
//Else both y are same so checking for x positions
else if (view1.IQ_x < view2.IQ_x) return NSOrderedAscending;
else if (x1 < x2) return NSOrderedAscending;
else if (view1.IQ_x > view2.IQ_x) return NSOrderedDescending;
else if (x1 > x2) return NSOrderedDescending;
else return NSOrderedSame;
}];

View File

@@ -27,93 +27,91 @@
@class UICollectionView, UIScrollView, UITableView, NSArray;
/**
@category UIView (IQ_UIView_Hierarchy)
@abstract UIView hierarchy category.
UIView hierarchy category.
*/
@interface UIView (IQ_UIView_Hierarchy)
///------------------------------
/// @name canBecomeFirstResponder
///------------------------------
/**
@property isAskingCanBecomeFirstResponder
@abstract Returns YES if IQKeyboardManager asking for `canBecomeFirstResponder. Useful when doing custom work in `textFieldShouldBeginEditing:` delegate.
Returns YES if IQKeyboardManager asking for `canBecomeFirstResponder. Useful when doing custom work in `textFieldShouldBeginEditing:` delegate.
*/
@property (nonatomic, readonly) BOOL isAskingCanBecomeFirstResponder;
///----------------------
/// @name viewControllers
///----------------------
/**
@property viewController
@abstract Returns the UIViewController object that manages the receiver.
Returns the UIViewController object that manages the receiver.
*/
@property (nonatomic, readonly, strong) UIViewController *viewController;
/**
@property topMostController
@abstract Returns the topMost UIViewController object in hierarchy.
Returns the topMost UIViewController object in hierarchy.
*/
@property (nonatomic, readonly, strong) UIViewController *topMostController;
///-----------------------------------
/// @name Superviews/Subviews/Siglings
///-----------------------------------
/**
@method superviewOfClassType:
@return Returns the superView of provided class type.
Returns the superView of provided class type.
*/
-(UIView*)superviewOfClassType:(Class)classType;
/**
@property responderSiblings
@abstract returns all siblings of the receiver which canBecomeFirstResponder.
Returns all siblings of the receiver which canBecomeFirstResponder.
*/
@property (nonatomic, readonly, copy) NSArray *responderSiblings;
/**
@property deepResponderViews
@abstract returns all deep subViews of the receiver which canBecomeFirstResponder.
Returns all deep subViews of the receiver which canBecomeFirstResponder.
*/
@property (nonatomic, readonly, copy) NSArray *deepResponderViews;
///-------------------------
/// @name Special TextFields
///-------------------------
/**
@property isSearchBarTextField
@abstract returns YES if the receiver object is UISearchBarTextField, otherwise return NO.
Returns YES if the receiver object is UISearchBarTextField, otherwise return NO.
*/
@property (nonatomic, getter=isSearchBarTextField, readonly) BOOL searchBarTextField;
/**
@property isAlertViewTextField
@abstract returns YES if the receiver object is UIAlertSheetTextField, otherwise return NO.
Returns YES if the receiver object is UIAlertSheetTextField, otherwise return NO.
*/
@property (nonatomic, getter=isAlertViewTextField, readonly) BOOL alertViewTextField;
///----------------
/// @name Transform
///----------------
/**
@method convertTransformToView
@return returns current view transform with respect to the 'toView'.
Returns current view transform with respect to the 'toView'.
*/
-(CGAffineTransform)convertTransformToView:(UIView*)toView;
///-----------------
/// @name Hierarchy
///-----------------
/**
@property subHierarchy
@abstract Returns a string that represent the information about it's subview's hierarchy. You can use this method to debug the subview's positions.
Returns a string that represent the information about it's subview's hierarchy. You can use this method to debug the subview's positions.
*/
@property (nonatomic, readonly, copy) NSString *subHierarchy;
/**
@property superHierarchy
@abstract Returns an string that represent the information about it's upper hierarchy. You can use this method to debug the superview's positions.
Returns an string that represent the information about it's upper hierarchy. You can use this method to debug the superview's positions.
*/
@property (nonatomic, readonly, copy) NSString *superHierarchy;
/**
@property debugHierarchy
@abstract Returns an string that represent the information about it's frame positions. You can use this method to debug self positions.
Returns an string that represent the information about it's frame positions. You can use this method to debug self positions.
*/
@property (nonatomic, readonly, copy) NSString *debugHierarchy;
@@ -121,29 +119,12 @@
/**
@category UIView (IQ_UIView_Frame)
@abstract UIView frame category.
NSObject category to used for logging purposes
*/
@interface UIView (IQ_UIView_Frame)
@property (nonatomic, assign) CGPoint IQ_origin;
@property (nonatomic, assign) CGSize IQ_size;
@property (nonatomic, assign) CGFloat IQ_x, IQ_y, IQ_width, IQ_height;
@property (nonatomic, assign) CGFloat IQ_left, IQ_right, IQ_top, IQ_bottom;
@property (nonatomic, assign) CGFloat IQ_centerX;
@property (nonatomic, assign) CGFloat IQ_centerY;
@property (nonatomic, readonly) CGPoint IQ_boundsCenter;
@end
@interface NSObject (IQ_Logging)
/**
@property _IQDescription
@abstract Short description for logging purpose.
Short description for logging purpose.
*/
@property (nonatomic, readonly, copy) NSString *_IQDescription;

View File

@@ -23,7 +23,10 @@
#import "IQUIView+Hierarchy.h"
#ifdef NSFoundationVersionNumber_iOS_5_1
#import <UIKit/UICollectionView.h>
#endif
#import <UIKit/UITableView.h>
#import <UIKit/UITextView.h>
#import <UIKit/UITextField.h>
@@ -61,7 +64,7 @@ Class UISearchBarTextFieldClass; //UISearchBar
-(void)_setIsAskingCanBecomeFirstResponder:(BOOL)isAskingCanBecomeFirstResponder
{
objc_setAssociatedObject(self, @selector(isAskingCanBecomeFirstResponder), @(isAskingCanBecomeFirstResponder), OBJC_ASSOCIATION_ASSIGN);
objc_setAssociatedObject(self, @selector(isAskingCanBecomeFirstResponder), [NSNumber numberWithBool:isAskingCanBecomeFirstResponder], OBJC_ASSOCIATION_ASSIGN);
}
-(BOOL)isAskingCanBecomeFirstResponder
@@ -177,11 +180,21 @@ Class UISearchBarTextFieldClass; //UISearchBar
//subviews are returning in opposite order. So I sorted it according the frames 'y'.
NSArray *subViews = [self.subviews sortedArrayUsingComparator:^NSComparisonResult(UIView *view1, UIView *view2) {
if (view1.IQ_y < view2.IQ_y) return NSOrderedAscending;
CGFloat x1 = CGRectGetMinX(view1.frame);
CGFloat y1 = CGRectGetMinY(view1.frame);
CGFloat x2 = CGRectGetMinX(view2.frame);
CGFloat y2 = CGRectGetMinY(view2.frame);
else if (view1.IQ_y > view2.IQ_y) return NSOrderedDescending;
if (y1 < y2) return NSOrderedAscending;
else return NSOrderedSame;
else if (y1 > y2) return NSOrderedDescending;
//Else both y are same so checking for x positions
else if (x1 < x2) return NSOrderedAscending;
else if (x1 > x2) return NSOrderedDescending;
else return NSOrderedSame;
}];
for (UITextField *textField in subViews)
@@ -287,7 +300,7 @@ Class UISearchBarTextFieldClass; //UISearchBar
{
NSMutableString *debugInfo = [[NSMutableString alloc] init];
[debugInfo appendFormat:@"%@: ( %.0f, %.0f, %.0f, %.0f )",NSStringFromClass([self class]),self.IQ_x,self.IQ_y,self.IQ_width,self.IQ_height];
[debugInfo appendFormat:@"%@: ( %.0f, %.0f, %.0f, %.0f )",NSStringFromClass([self class]), CGRectGetMinX(self.frame), CGRectGetMinY(self.frame), CGRectGetWidth(self.frame), CGRectGetHeight(self.frame)];
if ([self isKindOfClass:[UIScrollView class]])
{
@@ -315,110 +328,6 @@ Class UISearchBarTextFieldClass; //UISearchBar
@end
@implementation UIView (IQ_UIView_Frame)
-(CGFloat)IQ_x { return CGRectGetMinX(self.frame); }
-(CGFloat)IQ_y { return CGRectGetMinY(self.frame); }
-(CGFloat)IQ_width { return CGRectGetWidth(self.frame); }
-(CGFloat)IQ_height { return CGRectGetHeight(self.frame); }
-(CGPoint)IQ_origin { return self.frame.origin; }
-(CGSize)IQ_size { return self.frame.size; }
-(CGFloat)IQ_left { return CGRectGetMinX(self.frame); }
-(CGFloat)IQ_right { return CGRectGetMaxX(self.frame); }
-(CGFloat)IQ_top { return CGRectGetMinY(self.frame); }
-(CGFloat)IQ_bottom { return CGRectGetMaxY(self.frame); }
-(CGFloat)IQ_centerX { return self.center.x; }
-(CGFloat)IQ_centerY { return self.center.y; }
-(CGPoint)IQ_boundsCenter { return CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds)); };
-(void)setIQ_x:(CGFloat)IQ_x
{
CGRect frame = self.frame;
frame.origin.x = IQ_x;
self.frame = frame;
}
-(void)setIQ_y:(CGFloat)IQ_y
{
CGRect frame = self.frame;
frame.origin.y = IQ_y;
self.frame = frame;
}
-(void)setIQ_width:(CGFloat)IQ_width
{
CGRect frame = self.frame;
frame.size.width = IQ_width;
self.frame = frame;
}
-(void)setIQ_height:(CGFloat)IQ_height
{
CGRect frame = self.frame;
frame.size.height = IQ_height;
self.frame = frame;
}
-(void)setIQ_origin:(CGPoint)IQ_origin
{
CGRect frame = self.frame;
frame.origin = IQ_origin;
self.frame = frame;
}
-(void)setIQ_size:(CGSize)IQ_size
{
CGRect frame = self.frame;
frame.size = IQ_size;
self.frame = frame;
}
-(void)setIQ_left:(CGFloat)IQ_left
{
CGRect frame = self.frame;
frame.origin.x = IQ_left;
frame.size.width = MAX(self.IQ_right-IQ_left, 0);
self.frame = frame;
}
-(void)setIQ_right:(CGFloat)IQ_right
{
CGRect frame = self.frame;
frame.size.width = MAX(IQ_right-self.IQ_left, 0);
self.frame = frame;
}
-(void)setIQ_top:(CGFloat)IQ_top
{
CGRect frame = self.frame;
frame.origin.y = IQ_top;
frame.size.height = MAX(self.IQ_bottom-IQ_top, 0);
self.frame = frame;
}
-(void)setIQ_bottom:(CGFloat)IQ_bottom
{
CGRect frame = self.frame;
frame.size.height = MAX(IQ_bottom-self.IQ_top, 0);
self.frame = frame;
}
-(void)setIQ_centerX:(CGFloat)IQ_centerX
{
CGPoint center = self.center;
center.x = IQ_centerX;
self.center = center;
}
-(void)setIQ_centerY:(CGFloat)IQ_centerY
{
CGPoint center = self.center;
center.y = IQ_centerY;
self.center = center;
}
@end
@implementation NSObject (IQ_Logging)

View File

@@ -26,23 +26,21 @@
@class UIViewController;
/**
@category UIWindow (IQ_UIWindow_Hierarchy)
@abstract UIWindow hierarchy category.
UIWindow hierarchy category.
*/
@interface UIWindow (IQ_UIWindow_Hierarchy)
///----------------------
/// @name viewControllers
///----------------------
/**
@method topMostController
@return Returns the current Top Most ViewController in hierarchy.
Returns the current Top Most ViewController in hierarchy.
*/
@property (nonatomic, readonly, strong) UIViewController *topMostController;
/**
@method currentViewController
@return Returns the topViewController in stack of topMostController.
Returns the topViewController in stack of topMostController.
*/
@property (nonatomic, readonly, strong) UIViewController *currentViewController;

View File

@@ -26,49 +26,59 @@
#import <Foundation/NSObjCRuntime.h>
/* Set IQKEYBOARDMANAGER_DEBUG=1 in preprocessor macros under build settings to enable debugging.*/
///----------------
/// @name Debugging
///----------------
/**
@enum IQAutoToolbarManageBehaviour
@abstract AutoToolbar manage settings.
@const IQAutoToolbarBySubviews Creates Toolbar according to subview's hirarchy of Textfield's in view.
@const IQAutoToolbarByTag Creates Toolbar according to tag property of TextField's.
@const IQAutoToolbarByPosition Creates Toolbar according to the y,x position of textField in it's superview coordinate.
Set IQKEYBOARDMANAGER_DEBUG=1 in preprocessor macros under build settings to enable debugging.
*/
#ifndef NS_ENUM
///-----------------------------------
/// @name IQAutoToolbarManageBehaviour
///-----------------------------------
/**
`IQAutoToolbarBySubviews`
Creates Toolbar according to subview's hirarchy of Textfield's in view.
`IQAutoToolbarByTag`
Creates Toolbar according to tag property of TextField's.
`IQAutoToolbarByPosition`
Creates Toolbar according to the y,x position of textField in it's superview coordinate.
*/
#ifndef NS_ENUM
typedef enum IQAutoToolbarManageBehaviour {
IQAutoToolbarBySubviews,
IQAutoToolbarByTag,
IQAutoToolbarByPosition,
}IQAutoToolbarManageBehaviour;
#else
typedef NS_ENUM(NSInteger, IQAutoToolbarManageBehaviour) {
IQAutoToolbarBySubviews,
IQAutoToolbarByTag,
IQAutoToolbarByPosition,
};
#endif
///-------------------
/// @name Localization
///-------------------
#define IQLocalizedString(key, comment) [[NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"IQKeyboardManager" ofType:@"bundle"]] localizedStringForKey:(key) value:@"" table:@"IQKeyboardManager"]
#endif
/* XCode 5.0 Compatibility for NS_DESIGNATED_INITIALIZER*/
#ifndef NS_DESIGNATED_INITIALIZER
#if __has_attribute(objc_designated_initializer)
#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
#else
#define NS_DESIGNATED_INITIALIZER
#if __has_attribute(objc_designated_initializer)
#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
#else
#define NS_DESIGNATED_INITIALIZER
#endif
#endif
#endif
/*

View File

@@ -24,22 +24,18 @@
#ifndef IQKeyboardManagerConstantsInternal_h
#define IQKeyboardManagerConstantsInternal_h
//Xcode 4.5 compatibility
//Xcode 5 compatibility check
#ifdef NSFoundationVersionNumber_iOS_6_1
#define IQ_IS_IOS7_OR_GREATER (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1)
#define IQ_IS_XCODE_5_0_OR_GREATER 1
#else
#define IQ_IS_IOS7_OR_GREATER NO
#define IQ_IS_XCODE_5_0_OR_GREATER 0
#endif
//Xcode 5.0 compatibility
//Xcode 6 compatibility 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
#endif

View File

@@ -31,256 +31,236 @@
#import <UIKit/UITextInputTraits.h>
#if !(__has_feature(objc_instancetype))
#define instancetype id
#endif
@class UIFont;
/** @const kIQDoneButtonToolbarTag Default tag for toolbar with Done button -1002. */
extern NSInteger const kIQDoneButtonToolbarTag;
/* @const kIQPreviousNextButtonToolbarTag Default tag for toolbar with Previous/Next buttons -1005. */
extern NSInteger const kIQPreviousNextButtonToolbarTag;
/**
@author Iftekhar Qurashi
@related hack.iftekhar@gmail.com
@class IQKeyboardManager
@abstract Keyboard TextField/TextView Manager. A generic version of KeyboardManagement. https://developer.apple.com/Library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html
Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView. Neither need to write any code nor any setup required and much more. A generic version of KeyboardManagement. https://developer.apple.com/Library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html
*/
@interface IQKeyboardManager : NSObject
/*******************************************/
//UIKeyboard handling
///--------------------------
/// @name UIKeyboard handling
///--------------------------
/**
@method sharedManager
@return Returns the default singleton instance.
Returns the default singleton instance.
*/
+ (instancetype)sharedManager;
/**
@property enable
@abstract enable/disable managing distance between keyboard and textField. Default is YES(Enabled when class loads in `+(void)load` method).
Enable/disable managing distance between keyboard and textField. Default is YES(Enabled when class loads in `+(void)load` method).
*/
@property(nonatomic, assign, getter = isEnabled) BOOL enable;
/**
@property keyboardDistanceFromTextField
@abstract To set keyboard distance from textField. can't be less than zero. Default is 10.0.
To set keyboard distance from textField. can't be less than zero. Default is 10.0.
*/
@property(nonatomic, assign) CGFloat keyboardDistanceFromTextField;
/**
@property preventShowingBottomBlankSpace
@abstract Prevent keyboard manager to slide up the rootView to more than keyboard height. Default is YES.
Prevent keyboard manager to slide up the rootView to more than keyboard height. Default is YES.
*/
@property(nonatomic, assign) BOOL preventShowingBottomBlankSpace;
/*******************************************/
//IQToolbar handling
///-------------------------
/// @name IQToolbar handling
///-------------------------
/**
@property enableAutoToolbar
@abstract Automatic add the IQToolbar functionality. Default is YES.
Automatic add the IQToolbar functionality. Default is YES.
*/
@property(nonatomic, assign, getter = isEnableAutoToolbar) BOOL enableAutoToolbar;
/**
@property toolbarManageStyle
@abstract AutoToolbar managing behaviour. Default is IQAutoToolbarBySubviews.
AutoToolbar managing behaviour. Default is IQAutoToolbarBySubviews.
*/
@property(nonatomic, assign) IQAutoToolbarManageBehaviour toolbarManageBehaviour;
#ifdef NSFoundationVersionNumber_iOS_6_1
/**
@property shouldToolbarUsesTextFieldTintColor
@abstract If YES, then uses textField's tintColor property for IQToolbar, otherwise tint color is black. Default is NO.
If YES, then uses textField's tintColor property for IQToolbar, otherwise tint color is black. Default is NO.
*/
@property(nonatomic, assign) BOOL shouldToolbarUsesTextFieldTintColor NS_AVAILABLE_IOS(7_0);
@property(nonatomic, assign) BOOL shouldToolbarUsesTextFieldTintColor;
#endif
/**
@property shouldShowTextFieldPlaceholder
@abstract If YES, then it add the textField's placeholder text on IQToolbar. Default is YES.
If YES, then it add the textField's placeholder text on IQToolbar. Default is YES.
*/
@property(nonatomic, assign) BOOL shouldShowTextFieldPlaceholder;
/**
@property placeholderFont
@abstract Placeholder Font. Default is nil.
Placeholder Font. Default is nil.
*/
@property(nonatomic, strong) UIFont *placeholderFont;
/*******************************************/
//UITextView handling
///--------------------------
/// @name UITextView handling
///--------------------------
/**
@property canAdjustTextView
@abstract Adjust textView's frame when it is too big in height. Default is NO.
Adjust textView's frame when it is too big in height. Default is NO.
*/
@property(nonatomic, assign) BOOL canAdjustTextView;
/**
@property shouldFixTextViewClip
@abstract Adjust textView's contentInset to fix fix for iOS 7.0.x - http://stackoverflow.com/questions/18966675/uitextview-in-ios7-clips-the-last-line-of-text-string Default is YES.
Adjust textView's contentInset to fix fix for iOS 7.0.x - http://stackoverflow.com/questions/18966675/uitextview-in-ios7-clips-the-last-line-of-text-string Default is YES.
*/
@property(nonatomic, assign) BOOL shouldFixTextViewClip;
/*******************************************/
//UIKeyboard appearance overriding
///---------------------------------------
/// @name UIKeyboard appearance overriding
///---------------------------------------
/**
@property overrideKeyboardAppearance
@abstract Override the keyboardAppearance for all textField/textView. Default is NO.
Override the keyboardAppearance for all textField/textView. Default is NO.
*/
@property(nonatomic, assign) BOOL overrideKeyboardAppearance;
/**
@property keyboardAppearance
@abstract If overrideKeyboardAppearance is YES, then all the textField keyboardAppearance is set using this property.
If overrideKeyboardAppearance is YES, then all the textField keyboardAppearance is set using this property.
*/
@property(nonatomic, assign) UIKeyboardAppearance keyboardAppearance;
/*******************************************/
//UITextField/UITextView Resign handling
///---------------------------------------------
/// @name UITextField/UITextView Next/Previous/Resign handling
///---------------------------------------------
/**
@property shouldResignOnTouchOutside
@abstract Resigns Keyboard on touching outside of UITextField/View. Default is NO.
Resigns Keyboard on touching outside of UITextField/View. Default is NO.
*/
@property(nonatomic, assign) BOOL shouldResignOnTouchOutside;
/**
@method resignFirstResponder
@abstract Resigns currently first responder field.
Resigns currently first responder field.
*/
- (void)resignFirstResponder;
/*******************************************/
//UIScrollView handling
/**
Returns YES if can navigate to previous responder textField/textView, otherwise NO.
*/
@property (nonatomic, readonly) BOOL canGoPrevious;
/**
@property shouldRestoreScrollViewContentOffset
@abstract Restore scrollViewContentOffset when resigning from scrollView. Default is NO.
Returns YES if can navigate to next responder textField/textView, otherwise NO.
*/
@property (nonatomic, readonly) BOOL canGoNext;
/**
Navigate to previous responder textField/textView.
*/
- (void)goPrevious;
/**
Navigate to next responder textField/textView.
*/
- (void)goNext;
///----------------------------
/// @name UIScrollView handling
///----------------------------
/**
Restore scrollViewContentOffset when resigning from scrollView. Default is NO.
*/
@property(nonatomic, assign) BOOL shouldRestoreScrollViewContentOffset;
//UISound handling
///------------------------------------------------
/// @name UISound handling
///------------------------------------------------
/**
@property shouldPlayInputClicks
@abstract If YES, then it plays inputClick sound on next/previous/done click.
If YES, then it plays inputClick sound on next/previous/done click.
*/
@property(nonatomic, assign) BOOL shouldPlayInputClicks;
/*******************************************/
//UIAnimation handling
///---------------------------
/// @name UIAnimation handling
///---------------------------
/**
@property shouldAdoptDefaultKeyboardAnimation
If YES, then uses keyboard default animation curve style to move view, otherwise uses UIViewAnimationOptionCurveEaseInOut animation style. Default is YES.
@abstract If YES, then uses keyboard default animation curve style to move view, otherwise uses UIViewAnimationOptionCurveEaseInOut animation style. Default is YES.
@discussion Sometimes strange animations may be produced if uses default curve style animation in iOS 7 and changing the textFields very frequently.
@warning Sometimes strange animations may be produced if uses default curve style animation in iOS 7 and changing the textFields very frequently.
*/
@property(nonatomic, assign) BOOL shouldAdoptDefaultKeyboardAnimation;
/*******************************************/
//Class Level disabling methods
///------------------------------------
/// @name Class Level disabling methods
///------------------------------------
/**
@method disableInViewControllerClass:
@method removeDisableInViewControllerClass:
Disable adjusting view in disabledClass
@param disabledClass: Class in which library should not adjust view to show textField.
@param disabledClass Class in which library should not adjust view to show textField.
*/
-(void)disableInViewControllerClass:(Class)disabledClass;
/**
Re-enable adjusting textField in disabledClass
@param disabledClass Class in which library should re-enable adjust view to show textField.
*/
-(void)removeDisableInViewControllerClass:(Class)disabledClass;
/**
@method disableToolbarInViewControllerClass:
@method removeDisableToolbarInViewControllerClass:
Disable automatic toolbar creation in in toolbarDisabledClass
@param toolbarDisabledClass: Class in which library should not add toolbar over textField.
@param toolbarDisabledClass Class in which library should not add toolbar over textField.
*/
-(void)disableToolbarInViewControllerClass:(Class)toolbarDisabledClass;
/**
Re-enable automatic toolbar creation in in toolbarDisabledClass
@param toolbarDisabledClass Class in which library should re-enable automatic toolbar creation over textField.
*/
-(void)removeDisableToolbarInViewControllerClass:(Class)toolbarDisabledClass;
/**
@method considerToolbarPreviousNextInViewClass:
@method removeConsiderToolbarPreviousNextInViewClass:
Consider provided customView class as superView of all inner textField for calculating next/previous button logic.
@param toolbarPreviousNextConsideredClass: Custom UIView subclass Class in which library should consider all inner textField as siblings and add next/previous accordingly.
@param toolbarPreviousNextConsideredClass Custom UIView subclass Class in which library should consider all inner textField as siblings and add next/previous accordingly.
*/
-(void)considerToolbarPreviousNextInViewClass:(Class)toolbarPreviousNextConsideredClass;
-(void)removeConsiderToolbarPreviousNextInViewClass:(Class)toolbarPreviousNextConsideredClass;
/*******************************************/
//@final. Must not be used for subclassing.
/**
@method init
Remove Consideration for provided customView class as superView of all inner textField for calculating next/previous button logic.
@abstract Should create only one instance of class. Should not call init.
@param toolbarPreviousNextConsideredClass Custom UIView subclass Class in which library should remove consideration for all inner textField as superView.
*/
-(void)removeConsiderToolbarPreviousNextInViewClass:(Class)toolbarPreviousNextConsideredClass;
///------------------------------------------------
/// @name Must not be used for subclassing.
///------------------------------------------------
/**
Should create only one instance of class. Should not call init.
*/
- (instancetype)init __attribute__((unavailable("init is not available in IQKeyboardManager, Use sharedManager"))) NS_DESIGNATED_INITIALIZER;
/**
@method new
@abstract Should create only one instance of class. Should not call new.
Should create only one instance of class. Should not call new.
*/
+ (instancetype)new __attribute__((unavailable("new is not available in IQKeyboardManager, Use sharedManager")));
/*******************************************/
@end
///---------------------
/// @name IQToolbar tags
///---------------------
/**
Default tag for toolbar with Done button -1002.
*/
extern NSInteger const kIQDoneButtonToolbarTag;
/**
Default tag for toolbar with Previous/Next buttons -1005.
*/
extern NSInteger const kIQPreviousNextButtonToolbarTag;

View File

@@ -35,10 +35,15 @@
#import <UIKit/UITextField.h>
#import <UIKit/UITextView.h>
#import <UIKit/UITableViewController.h>
#import <UIKit/UINavigationController.h>
#import <UIKit/UITableView.h>
#import <UIKit/UICollectionView.h>
#import <UIKit/UITouch.h>
#ifdef NSFoundationVersionNumber_iOS_5_1
#import <UIKit/UICollectionView.h>
#import <UIKit/NSLayoutConstraint.h>
#endif
NSInteger const kIQDoneButtonToolbarTag = -1002;
NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
@@ -62,6 +67,9 @@ void _IQShowLog(NSString *logString);
- (void)textFieldViewDidEndEditing:(NSNotification*)notification;
- (void)textFieldViewDidChange:(NSNotification*)notification;
// Rotation notification
- (void)willChangeStatusBarOrientation:(NSNotification*)aNotification;
// Tap Recognizer
- (void)tapRecognized:(UITapGestureRecognizer*)gesture;
@@ -124,7 +132,12 @@ void _IQShowLog(NSString *logString);
UITapGestureRecognizer *_tapGesture;
/*******************************************/
/** Default toolbar tintColor to be used within the project. Default is black. */
UIColor *_defaultToolbarTintColor;
/*******************************************/
/** Set of restricted classes for library */
NSMutableSet *_disabledClasses;
@@ -158,12 +171,17 @@ void _IQShowLog(NSString *logString);
//IQToolbar handling
@synthesize enableAutoToolbar = _enableAutoToolbar;
@synthesize toolbarManageBehaviour = _toolbarManageBehaviour;
#ifdef NSFoundationVersionNumber_iOS_6_1
@synthesize shouldToolbarUsesTextFieldTintColor = _shouldToolbarUsesTextFieldTintColor;
#endif
@synthesize shouldShowTextFieldPlaceholder = _shouldShowTextFieldPlaceholder;
@synthesize placeholderFont = _placeholderFont;
//TextView handling
@synthesize canAdjustTextView = _canAdjustTextView;
@synthesize shouldFixTextViewClip = _shouldFixTextViewClip;
//Resign handling
@synthesize shouldResignOnTouchOutside = _shouldResignOnTouchOutside;
@@ -174,6 +192,8 @@ void _IQShowLog(NSString *logString);
//Animation handling
@synthesize shouldAdoptDefaultKeyboardAnimation = _shouldAdoptDefaultKeyboardAnimation;
//ScrollView handling
@synthesize shouldRestoreScrollViewContentOffset= _shouldRestoreScrollViewContentOffset;
#pragma mark - Initializing functions
@@ -221,11 +241,11 @@ void _IQShowLog(NSString *logString);
//Setting it's initial values
_enable = NO;
_defaultToolbarTintColor = [UIColor blackColor];
[self setCanAdjustTextView:NO];
[self setShouldPlayInputClicks:NO];
[self setShouldResignOnTouchOutside:NO];
[self setOverrideKeyboardAppearance:NO];
[self setShouldToolbarUsesTextFieldTintColor:NO];
[self setKeyboardAppearance:UIKeyboardAppearanceDefault];
[self setEnableAutoToolbar:YES];
@@ -239,7 +259,17 @@ void _IQShowLog(NSString *logString);
//Initializing disabled classes Set.
_disabledClasses = [[NSMutableSet alloc] initWithObjects:[UITableViewController class], nil];
_disabledToolbarClasses = [[NSMutableSet alloc] init];
#ifdef NSFoundationVersionNumber_iOS_6_1
[self setShouldToolbarUsesTextFieldTintColor:NO];
#endif
#ifdef NSFoundationVersionNumber_iOS_5_1
_toolbarPreviousNextConsideredClass = [[NSMutableSet alloc] initWithObjects:[UITableView class],[UICollectionView class], nil];
#else
_toolbarPreviousNextConsideredClass = [[NSMutableSet alloc] initWithObjects:[UITableView class], nil];
#endif
});
}
return self;
@@ -383,7 +413,7 @@ void _IQShowLog(NSString *logString);
//frame size needs to be adjusted on iOS8 due to orientation API changes.
if (IQ_IS_IOS8_OR_GREATER)
{
frame.size = controller.view.IQ_size;
frame.size = controller.view.frame.size;
}
// If can't get rootViewController then printing warning to user.
@@ -394,6 +424,11 @@ void _IQShowLog(NSString *logString);
[UIView animateWithDuration:_animationDuration delay:0 options:(_animationCurve|UIViewAnimationOptionBeginFromCurrentState) animations:^{
// Setting it's new frame
[controller.view setFrame:frame];
//Animating content (Bug ID: #160)
[controller.view setNeedsLayout];
[controller.view layoutIfNeeded];
_IQShowLog([NSString stringWithFormat:@"Set %@ frame to : %@",[controller _IQDescription],NSStringFromCGRect(frame)]);
} completion:NULL];
}
@@ -427,8 +462,24 @@ void _IQShowLog(NSString *logString);
// Getting RootViewRect.
CGRect rootViewRect = [[rootController view] frame];
//Getting statusBarFrame
CGFloat topLayoutGuide = 0;
CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
switch (interfaceOrientation)
{
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
topLayoutGuide = CGRectGetWidth(statusBarFrame);
break;
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
topLayoutGuide = CGRectGetHeight(statusBarFrame);
break;
default:
break;
}
CGFloat move = 0;
// Move positive = textField is hidden.
// Move negative = textField is showing.
@@ -437,16 +488,16 @@ void _IQShowLog(NSString *logString);
switch (interfaceOrientation)
{
case UIInterfaceOrientationLandscapeLeft:
move = MIN(CGRectGetMinX(textFieldViewRect)-(CGRectGetWidth(statusBarFrame)+5), CGRectGetMaxX(textFieldViewRect)-(keyWindow.IQ_width-_kbSize.width));
move = MIN(CGRectGetMinX(textFieldViewRect)-(topLayoutGuide+5), CGRectGetMaxX(textFieldViewRect)-(CGRectGetWidth(keyWindow.frame)-_kbSize.width));
break;
case UIInterfaceOrientationLandscapeRight:
move = MIN(keyWindow.IQ_width-CGRectGetMaxX(textFieldViewRect)-(CGRectGetWidth(statusBarFrame)+5), _kbSize.width-CGRectGetMinX(textFieldViewRect));
move = MIN(CGRectGetWidth(keyWindow.frame)-CGRectGetMaxX(textFieldViewRect)-(topLayoutGuide+5), _kbSize.width-CGRectGetMinX(textFieldViewRect));
break;
case UIInterfaceOrientationPortrait:
move = MIN(CGRectGetMinY(textFieldViewRect)-(CGRectGetHeight(statusBarFrame)+5), CGRectGetMaxY(textFieldViewRect)-(keyWindow.IQ_height-_kbSize.height));
move = MIN(CGRectGetMinY(textFieldViewRect)-(topLayoutGuide+5), CGRectGetMaxY(textFieldViewRect)-(CGRectGetHeight(keyWindow.frame)-_kbSize.height));
break;
case UIInterfaceOrientationPortraitUpsideDown:
move = MIN(keyWindow.IQ_height-CGRectGetMaxY(textFieldViewRect)-(CGRectGetHeight(statusBarFrame)+5), _kbSize.height-CGRectGetMinY(textFieldViewRect));
move = MIN(CGRectGetHeight(keyWindow.frame)-CGRectGetMaxY(textFieldViewRect)-(topLayoutGuide+5), _kbSize.height-CGRectGetMinY(textFieldViewRect));
break;
default:
break;
@@ -520,7 +571,7 @@ void _IQShowLog(NSString *logString);
UIScrollView *superScrollView = _lastScrollView;
//Looping in upper hierarchy until we don't found any scrollView in it's upper hirarchy till UIWindow object.
while (superScrollView && (move>0?(move > (-superScrollView.contentOffset.y)):superScrollView.contentOffset.y>0) )
while (superScrollView && (move>0?(move > (-superScrollView.contentOffset.y-superScrollView.contentInset.top)):superScrollView.contentOffset.y>0) )
{
//Getting lastViewRect.
CGRect lastViewRect = [[lastView superview] convertRect:lastView.frame toView:superScrollView];
@@ -531,8 +582,56 @@ void _IQShowLog(NSString *logString);
//Rearranging the expected Y offset according to the view.
shouldOffsetY = MIN(shouldOffsetY, lastViewRect.origin.y/*-5*/); //-5 is for good UI.//Commenting -5 (Bug ID: #69)
//Subtracting the Y offset from the move variable, because we are going to change scrollView's contentOffset.y to shouldOffsetY.
move -= (shouldOffsetY-superScrollView.contentOffset.y);
//[superScrollView superviewOfClassType:[UIScrollView class]] == nil If processing scrollView is last scrollView in upper hierarchy (there is no other scrollView upper hierrchy.)
//[_textFieldView isKindOfClass:[UITextView class]] If is a UITextView type
//shouldOffsetY > 0 shouldOffsetY must be greater than in order to keep distance from navigationBar (Bug ID: #92)
if ([_textFieldView isKindOfClass:[UITextView class]] && [superScrollView superviewOfClassType:[UIScrollView class]] == nil && shouldOffsetY > 0)
{
CGFloat maintainTopLayout = 0;
//When uncommenting this, each calculation goes to well, but don't know why scrollView doesn't adjusting it's contentOffset at bottom
// if ([_textFieldView.viewController respondsToSelector:@selector(topLayoutGuide)])
// maintainTopLayout = [_textFieldView.viewController.topLayoutGuide length];
// else
maintainTopLayout = CGRectGetMaxY(_textFieldView.viewController.navigationController.navigationBar.frame);
maintainTopLayout+= 10; //For good UI
// Converting Rectangle according to window bounds.
CGRect currentTextFieldViewRect = [[_textFieldView superview] convertRect:_textFieldView.frame toView:keyWindow];
CGFloat expectedFixDistance = shouldOffsetY;
//Calculating expected fix distance which needs to be managed from navigation bar
switch (interfaceOrientation)
{
case UIInterfaceOrientationLandscapeLeft:
expectedFixDistance = CGRectGetMinX(currentTextFieldViewRect) - maintainTopLayout;
break;
case UIInterfaceOrientationLandscapeRight:
expectedFixDistance = (CGRectGetWidth(keyWindow.frame)-CGRectGetMaxX(currentTextFieldViewRect)) - maintainTopLayout;
break;
case UIInterfaceOrientationPortrait:
expectedFixDistance = CGRectGetMinY(currentTextFieldViewRect) - maintainTopLayout;
break;
case UIInterfaceOrientationPortraitUpsideDown:
expectedFixDistance = (CGRectGetHeight(keyWindow.frame)-CGRectGetMaxY(currentTextFieldViewRect)) - maintainTopLayout;
break;
default:
break;
}
//Now if expectedOffsetY (superScrollView.contentOffset.y + expectedFixDistance) is lower than current shouldOffsetY, which means we're in a position where navigationBar up and hide, then reducing shouldOffsetY with expectedOffsetY (superScrollView.contentOffset.y + expectedFixDistance)
shouldOffsetY = MIN(shouldOffsetY, superScrollView.contentOffset.y + expectedFixDistance);
//Setting move to 0 because now we don't want to move any view anymore (All will be managed by our contentInset logic.
move = 0;
}
else
{
//Subtracting the Y offset from the move variable, because we are going to change scrollView's contentOffset.y to shouldOffsetY.
move -= (shouldOffsetY-superScrollView.contentOffset.y);
}
//Getting problem while using `setContentOffset:animated:`, So I used animation API.
[UIView animateWithDuration:_animationDuration delay:0 options:(_animationCurve|UIViewAnimationOptionBeginFromCurrentState) animations:^{
@@ -559,13 +658,13 @@ void _IQShowLog(NSString *logString);
switch (interfaceOrientation)
{
case UIInterfaceOrientationLandscapeLeft:
bottom = _kbSize.width-(keyWindow.IQ_width-CGRectGetMaxX(lastScrollViewRect));
bottom = _kbSize.width-(CGRectGetWidth(keyWindow.frame)-CGRectGetMaxX(lastScrollViewRect));
break;
case UIInterfaceOrientationLandscapeRight:
bottom = _kbSize.width-CGRectGetMinX(lastScrollViewRect);
break;
case UIInterfaceOrientationPortrait:
bottom = _kbSize.height-(keyWindow.IQ_height-CGRectGetMaxY(lastScrollViewRect));
bottom = _kbSize.height-(CGRectGetHeight(keyWindow.frame)-CGRectGetMaxY(lastScrollViewRect));
break;
case UIInterfaceOrientationPortraitUpsideDown:
bottom = _kbSize.height-CGRectGetMinY(lastScrollViewRect);
@@ -578,7 +677,6 @@ void _IQShowLog(NSString *logString);
UIEdgeInsets movedInsets = _lastScrollView.contentInset;
movedInsets.bottom = MAX(_startingContentInsets.bottom, bottom);
// movedInsets.bottom = MAX(0, (_lastScrollView.contentOffset.y+_lastScrollView.IQ_height)-MAX(_lastScrollView.contentSize.height, _lastScrollView.IQ_height));
_IQShowLog([NSString stringWithFormat:@"%@ old ContentInset : %@",[_lastScrollView _IQDescription], NSStringFromUIEdgeInsets(_lastScrollView.contentInset)]);
@@ -599,22 +697,24 @@ void _IQShowLog(NSString *logString);
//Going ahead. No else if.
}
//Special case for UITextView(Readjusting the move variable when textView hight is too big to fit on screen).
//If we have permission to adjust the textView, then let's do it on behalf of user. (Enhancement ID: #15)
//Added _isTextFieldViewFrameChanged. (Bug ID: #92)
if (_canAdjustTextView && [_textFieldView isKindOfClass:[UITextView class]] && _keyboardManagerFlags.isTextFieldViewFrameChanged == NO)
//Special case for UITextView(Readjusting the move variable when textView hight is too big to fit on screen)
//_canAdjustTextView If we have permission to adjust the textView, then let's do it on behalf of user (Enhancement ID: #15)
//_lastScrollView If not having inside any scrollView, (now contentInset manages the full screen textView.
//[_textFieldView isKindOfClass:[UITextView class]] If is a UITextView type
//_isTextFieldViewFrameChanged If frame is not change by library in past (Bug ID: #92)
if (_canAdjustTextView && (_lastScrollView == NO) && [_textFieldView isKindOfClass:[UITextView class]] && _keyboardManagerFlags.isTextFieldViewFrameChanged == NO)
{
CGFloat textViewHeight = _textFieldView.IQ_height;
CGFloat textViewHeight = CGRectGetHeight(_textFieldView.frame);
switch (interfaceOrientation)
{
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
textViewHeight = MIN(textViewHeight, (keyWindow.IQ_width-_kbSize.width-(CGRectGetWidth(statusBarFrame)+5)));
textViewHeight = MIN(textViewHeight, (CGRectGetWidth(keyWindow.frame)-_kbSize.width-(topLayoutGuide+5)));
break;
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
textViewHeight = MIN(textViewHeight, (keyWindow.IQ_height-_kbSize.height-(CGRectGetHeight(statusBarFrame)+5)));
textViewHeight = MIN(textViewHeight, (CGRectGetHeight(keyWindow.frame)-_kbSize.height-(topLayoutGuide+5)));
break;
default:
break;
@@ -624,7 +724,9 @@ void _IQShowLog(NSString *logString);
_IQShowLog([NSString stringWithFormat:@"%@ Old Frame : %@",[_textFieldView _IQDescription], NSStringFromCGRect(_textFieldView.frame)]);
_textFieldView.IQ_height = textViewHeight;
CGRect textFieldViewRect = _textFieldView.frame;
textFieldViewRect.size.height = textViewHeight;
_textFieldView.frame = textFieldViewRect;
_keyboardManagerFlags.isTextFieldViewFrameChanged = YES;
_IQShowLog([NSString stringWithFormat:@"%@ New Frame : %@",[_textFieldView _IQDescription], NSStringFromCGRect(_textFieldView.frame)]);
@@ -653,10 +755,10 @@ void _IQShowLog(NSString *logString);
{
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
minimumY = keyWindow.IQ_width-rootViewRect.size.height-statusBarFrame.size.width-(_kbSize.width-_keyboardDistanceFromTextField); break;
minimumY = CGRectGetWidth(keyWindow.frame)-rootViewRect.size.height-topLayoutGuide-(_kbSize.width-_keyboardDistanceFromTextField); break;
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
minimumY = (keyWindow.IQ_height-rootViewRect.size.height-statusBarFrame.size.height)/2-(_kbSize.height-_keyboardDistanceFromTextField); break;
minimumY = (CGRectGetHeight(keyWindow.frame)-rootViewRect.size.height-topLayoutGuide)/2-(_kbSize.height-_keyboardDistanceFromTextField); break;
default: break;
}
@@ -795,7 +897,7 @@ void _IQShowLog(NSString *logString);
if (_shouldAdoptDefaultKeyboardAnimation)
{
// Getting keyboard animation.
_animationCurve = [[aNotification userInfo][UIKeyboardAnimationCurveUserInfoKey] integerValue];
_animationCurve = [[[aNotification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] integerValue];
_animationCurve = _animationCurve<<16;
}
else
@@ -804,7 +906,7 @@ void _IQShowLog(NSString *logString);
}
// Getting keyboard animation duration
CGFloat duration = [[aNotification userInfo][UIKeyboardAnimationDurationUserInfoKey] floatValue];
CGFloat duration = [[[aNotification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
//Saving animation duration
if (duration != 0.0) _animationDuration = duration;
@@ -813,7 +915,7 @@ void _IQShowLog(NSString *logString);
// Getting UIKeyboardSize.
// CGRect screenRect = [self keyWindow].bounds;
CGRect kbFrame = [[aNotification userInfo][UIKeyboardFrameEndUserInfoKey] CGRectValue];
CGRect kbFrame = [[[aNotification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
_kbSize = kbFrame.size;
_IQShowLog([NSString stringWithFormat:@"UIKeyboard Size : %@",NSStringFromCGSize(_kbSize)]);
@@ -898,7 +1000,7 @@ void _IQShowLog(NSString *logString);
_keyboardManagerFlags.isKeyboardShowing = NO;
// Getting keyboard animation duration
CGFloat aDuration = [[aNotification userInfo][UIKeyboardAnimationDurationUserInfoKey] floatValue];
CGFloat aDuration = [[[aNotification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
if (aDuration!= 0.0f)
{
// Setitng keyboard animation duration
@@ -918,6 +1020,25 @@ void _IQShowLog(NSString *logString);
_IQShowLog([NSString stringWithFormat:@"Restoring %@ contentInset to : %@ and contentOffset to : %@",[_lastScrollView _IQDescription],NSStringFromUIEdgeInsets(_startingContentInsets),NSStringFromCGPoint(_startingContentOffset)]);
// TODO: restore scrollView state
// This is temporary solution. Have to implement the save and restore scrollView state
UIScrollView *superscrollView = _lastScrollView;
while ((superscrollView = (UIScrollView*)[superscrollView superviewOfClassType:[UIScrollView class]]))
{
MAX(superscrollView.contentSize.height, CGRectGetHeight(superscrollView.frame));
CGSize contentSize = CGSizeMake(MAX(superscrollView.contentSize.width, CGRectGetWidth(superscrollView.frame)), MAX(superscrollView.contentSize.height, CGRectGetHeight(superscrollView.frame)));
CGFloat minimumY = contentSize.height-CGRectGetHeight(superscrollView.frame);
if (minimumY<superscrollView.contentOffset.y)
{
superscrollView.contentOffset = CGPointMake(superscrollView.contentOffset.x, minimumY);
_IQShowLog([NSString stringWithFormat:@"Restoring %@ contentOffset to : %@",[superscrollView _IQDescription],NSStringFromCGPoint(superscrollView.contentOffset)]);
}
}
} completion:NULL];
}
@@ -927,7 +1048,7 @@ void _IQShowLog(NSString *logString);
//frame size needs to be adjusted on iOS8 due to orientation API changes.
if (IQ_IS_IOS8_OR_GREATER)
{
_topViewBeginRect.size = _rootViewController.view.IQ_size;
_topViewBeginRect.size = _rootViewController.view.frame.size;
}
//Used UIViewAnimationOptionBeginFromCurrentState to minimize strange animations.
@@ -936,6 +1057,11 @@ void _IQShowLog(NSString *logString);
_IQShowLog([NSString stringWithFormat:@"Restoring %@ frame to : %@",[_rootViewController _IQDescription],NSStringFromCGRect(_topViewBeginRect)]);
// Setting it's new frame
[_rootViewController.view setFrame:_topViewBeginRect];
//Animating content (Bug ID: #160)
[_rootViewController.view setNeedsLayout];
[_rootViewController.view layoutIfNeeded];
} completion:NULL];
_rootViewController = nil;
}
@@ -1171,7 +1297,7 @@ void _IQShowLog(NSString *logString);
{
// Retaining textFieldView
UIView *textFieldRetain = _textFieldView;
//Resigning first responder
BOOL isResignFirstResponder = [_textFieldView resignFirstResponder];
@@ -1183,6 +1309,126 @@ void _IQShowLog(NSString *logString);
_IQShowLog([NSString stringWithFormat:@"Refuses to Resign first responder: %@",[_textFieldView _IQDescription]]);
}
else if (textFieldRetain.doneInvocation)
{
[textFieldRetain.doneInvocation invoke];
}
}
}
/** Returns YES if can navigate to previous responder textField/textView, otherwise NO. */
-(BOOL)canGoPrevious
{
//Getting all responder view's.
NSArray *textFields = [self responderViews];
if ([textFields containsObject:_textFieldView])
{
//Getting index of current textField.
NSUInteger index = [textFields indexOfObject:_textFieldView];
//If it is not first textField. then it's previous object can becomeFirstResponder.
if (index > 0)
{
return YES;
}
}
return NO;
}
/** Returns YES if can navigate to next responder textField/textView, otherwise NO. */
-(BOOL)canGoNext
{
//Getting all responder view's.
NSArray *textFields = [self responderViews];
if ([textFields containsObject:_textFieldView])
{
//Getting index of current textField.
NSUInteger index = [textFields indexOfObject:_textFieldView];
//If it is not last textField. then it's next object becomeFirstResponder.
if (index < textFields.count-1)
{
return YES;
}
}
return NO;
}
/** Navigate to previous responder textField/textView. */
-(void)goPrevious
{
//Getting all responder view's.
NSArray *textFields = [self responderViews];
if ([textFields containsObject:_textFieldView])
{
//Getting index of current textField.
NSUInteger index = [textFields indexOfObject:_textFieldView];
//If it is not first textField. then it's previous object becomeFirstResponder.
if (index > 0)
{
UITextField *nextTextField = [textFields objectAtIndex:index-1];
// Retaining textFieldView
UIView *textFieldRetain = _textFieldView;
BOOL isAcceptAsFirstResponder = [nextTextField becomeFirstResponder];
// If it refuses then becoming previous textFieldView as first responder again. (Bug ID: #96)
if (isAcceptAsFirstResponder == NO)
{
//If next field refuses to become first responder then restoring old textField as first responder.
[textFieldRetain becomeFirstResponder];
_IQShowLog([NSString stringWithFormat:@"Refuses to become first responder: %@",[nextTextField _IQDescription]]);
}
else if (textFieldRetain.previousInvocation)
{
[textFieldRetain.previousInvocation invoke];
}
}
}
}
/** Navigate to next responder textField/textView. */
-(void)goNext
{
//Getting all responder view's.
NSArray *textFields = [self responderViews];
if ([textFields containsObject:_textFieldView])
{
//Getting index of current textField.
NSUInteger index = [textFields indexOfObject:_textFieldView];
//If it is not last textField. then it's next object becomeFirstResponder.
if (index < textFields.count-1)
{
UITextField *nextTextField = [textFields objectAtIndex:index+1];
// Retaining textFieldView
UIView *textFieldRetain = _textFieldView;
BOOL isAcceptAsFirstResponder = [nextTextField becomeFirstResponder];
// If it refuses then becoming previous textFieldView as first responder again. (Bug ID: #96)
if (isAcceptAsFirstResponder == NO)
{
//If next field refuses to become first responder then restoring old textField as first responder.
[textFieldRetain becomeFirstResponder];
_IQShowLog([NSString stringWithFormat:@"Refuses to become first responder: %@",[nextTextField _IQDescription]]);
}
else if (textFieldRetain.nextInvocation)
{
[textFieldRetain.nextInvocation invoke];
}
}
}
}
@@ -1252,7 +1498,11 @@ void _IQShowLog(NSString *logString);
// If only one object is found, then adding only Done button.
if (siblings.count==1)
{
UITextField *textField = [siblings firstObject];
UITextField *textField = nil;
if ([siblings count])
textField = [siblings objectAtIndex:0];
//Either there is no inputAccessoryView or if accessoryView is not appropriate for current situation(There is Previous/Next/Done toolbar).
if (![textField inputAccessoryView] || ([[textField inputAccessoryView] tag] == kIQPreviousNextButtonToolbarTag))
@@ -1277,7 +1527,7 @@ void _IQShowLog(NSString *logString);
IQToolbar *toolbar = (IQToolbar*)[textField inputAccessoryView];
//Bar style according to keyboard appearance
if ([textField respondsToSelector:@selector(keyboardAppearance)])
if (IQ_IS_IOS7_OR_GREATER && [textField respondsToSelector:@selector(keyboardAppearance)])
{
switch ([(UITextField*)textField keyboardAppearance])
{
@@ -1292,9 +1542,10 @@ void _IQShowLog(NSString *logString);
{
toolbar.barStyle = UIBarStyleDefault;
//Setting toolbar tintColor // (Enhancement ID: #30)
if (_shouldToolbarUsesTextFieldTintColor && [toolbar respondsToSelector:@selector(tintColor)])
[toolbar setTintColor:[textField tintColor]];
#ifdef NSFoundationVersionNumber_iOS_6_1
if ([toolbar respondsToSelector:@selector(tintColor)])
[toolbar setTintColor:_shouldToolbarUsesTextFieldTintColor?[textField tintColor]:_defaultToolbarTintColor];
#endif
}
break;
}
@@ -1331,7 +1582,7 @@ void _IQShowLog(NSString *logString);
IQToolbar *toolbar = (IQToolbar*)[textField inputAccessoryView];
//Bar style according to keyboard appearance
if ([textField respondsToSelector:@selector(keyboardAppearance)])
if (IQ_IS_IOS7_OR_GREATER && [textField respondsToSelector:@selector(keyboardAppearance)])
{
switch ([(UITextField*)textField keyboardAppearance])
{
@@ -1346,9 +1597,12 @@ void _IQShowLog(NSString *logString);
{
toolbar.barStyle = UIBarStyleDefault;
#ifdef NSFoundationVersionNumber_iOS_6_1
//Setting toolbar tintColor // (Enhancement ID: #30)
if (_shouldToolbarUsesTextFieldTintColor && [toolbar respondsToSelector:@selector(tintColor)])
[toolbar setTintColor:[textField tintColor]];
if ([toolbar respondsToSelector:@selector(tintColor)])
[toolbar setTintColor:_shouldToolbarUsesTextFieldTintColor?[textField tintColor]:_defaultToolbarTintColor];
#endif
}
break;
}
@@ -1356,7 +1610,7 @@ void _IQShowLog(NSString *logString);
//In case of UITableView (Special), the next/previous buttons has to be refreshed everytime. (Bug ID: #56)
// If firstTextField, then previous should not be enabled.
if (siblings[0] == textField)
if ([siblings objectAtIndex:0] == textField)
{
[textField setEnablePrevious:NO next:YES];
}
@@ -1403,37 +1657,9 @@ void _IQShowLog(NSString *logString);
[[UIDevice currentDevice] playInputClick];
}
//Getting all responder view's.
NSArray *textFields = [self responderViews];
if ([textFields containsObject:_textFieldView])
if ([self canGoPrevious])
{
//Getting index of current textField.
NSUInteger index = [textFields indexOfObject:_textFieldView];
//If it is not first textField. then it's previous object becomeFirstResponder.
if (index > 0)
{
UITextField *nextTextField = textFields[index-1];
// Retaining textFieldView
UIView *textFieldRetain = _textFieldView;
BOOL isAcceptAsFirstResponder = [nextTextField becomeFirstResponder];
// If it refuses then becoming previous textFieldView as first responder again. (Bug ID: #96)
if (isAcceptAsFirstResponder == NO)
{
//If next field refuses to become first responder then restoring old textField as first responder.
[textFieldRetain becomeFirstResponder];
_IQShowLog([NSString stringWithFormat:@"Refuses to become first responder: %@",[nextTextField _IQDescription]]);
}
else if (textFieldRetain.previousInvocation)
{
[textFieldRetain.previousInvocation invoke];
}
}
[self goPrevious];
}
}
@@ -1447,37 +1673,9 @@ void _IQShowLog(NSString *logString);
[[UIDevice currentDevice] playInputClick];
}
//Getting all responder view's.
NSArray *textFields = [self responderViews];
if ([textFields containsObject:_textFieldView])
if ([self canGoNext])
{
//Getting index of current textField.
NSUInteger index = [textFields indexOfObject:_textFieldView];
//If it is not last textField. then it's next object becomeFirstResponder.
if (index < textFields.count-1)
{
UITextField *nextTextField = textFields[index+1];
// Retaining textFieldView
UIView *textFieldRetain = _textFieldView;
BOOL isAcceptAsFirstResponder = [nextTextField becomeFirstResponder];
// If it refuses then becoming previous textFieldView as first responder again. (Bug ID: #96)
if (isAcceptAsFirstResponder == NO)
{
//If next field refuses to become first responder then restoring old textField as first responder.
[textFieldRetain becomeFirstResponder];
_IQShowLog([NSString stringWithFormat:@"Refuses to become first responder: %@",[nextTextField _IQDescription]]);
}
else if (textFieldRetain.nextInvocation)
{
[textFieldRetain.nextInvocation invoke];
}
}
[self goNext];
}
}
@@ -1491,24 +1689,7 @@ void _IQShowLog(NSString *logString);
[[UIDevice currentDevice] playInputClick];
}
// Retaining textFieldView
UIView *textFieldRetain = _textFieldView;
//Resigning first responder
BOOL isResignFirstResponder = [_textFieldView resignFirstResponder];
// If it refuses then becoming it as first responder again. (Bug ID: #96)
if (isResignFirstResponder == NO)
{
//If it refuses to resign then becoming it first responder again for getting notifications callback.
[textFieldRetain becomeFirstResponder];
_IQShowLog([NSString stringWithFormat:@"Refuses to Resign first responder: %@",[_textFieldView _IQDescription]]);
}
else if (textFieldRetain.doneInvocation)
{
[textFieldRetain.doneInvocation invoke];
}
[self resignFirstResponder];
}
#pragma mark - Tracking untracking

View File

@@ -29,72 +29,74 @@
#import <UIKit/UITextField.h>
#import <UIKit/UITextView.h>
#if !(__has_feature(objc_instancetype))
#define instancetype id
#endif
@class UITextField,UIView, UIViewController;
/**
@author Iftekhar Qurashi
@related hack.iftekhar@gmail.com
@class IQKeyboardReturnKeyHandler
@abstract Manages the return key to work like next/done in a view hierarchy.
Manages the return key to work like next/done in a view hierarchy.
*/
@interface IQKeyboardReturnKeyHandler : NSObject
///----------------------
/// @name Initializations
///----------------------
/**
@method initWithViewController
@abstract Add all the textFields available in UIViewController's view.
Add all the textFields available in UIViewController's view.
*/
-(instancetype)initWithViewController:(UIViewController*)controller NS_DESIGNATED_INITIALIZER;
///---------------
/// @name Settings
///---------------
/**
@method delegate
@abstract textField's delegates.
Delegate of textField/textView.
*/
@property(nonatomic, weak) id<UITextFieldDelegate,UITextViewDelegate> delegate;
/**
@property toolbarManageBehaviour
@abstract It help to choose the lastTextField instance from sibling responderViews. Default is IQAutoToolbarBySubviews.
It help to choose the lastTextField instance from sibling responderViews. Default is IQAutoToolbarBySubviews.
*/
@property(nonatomic, assign) IQAutoToolbarManageBehaviour toolbarManageBehaviour;
/**
@property lastTextFieldReturnKeyType
@abstract Set the last textfield return key type. Default is UIReturnKeyDefault.
Set the last textfield return key type. Default is UIReturnKeyDefault.
*/
@property(nonatomic, assign) UIReturnKeyType lastTextFieldReturnKeyType;
///----------------------------------------------
/// @name Registering/Unregistering textFieldView
///----------------------------------------------
/**
@method addTextFieldView
Should pass UITextField/UITextView intance. Assign textFieldView delegate to self, change it's returnKeyType.
@abstract Should pass UITextField/UITextView intance. Assign textFieldView delegate to self, change it's returnKeyType.
@param textFieldView UITextField/UITextView object to register.
*/
-(void)addTextFieldView:(UIView*)textFieldView;
/**
@method removeTextFieldView
@abstract Should pass UITextField/UITextView intance. Restore it's textFieldView delegate and it's returnKeyType.
Should pass UITextField/UITextView intance. Restore it's textFieldView delegate and it's returnKeyType.
@param textFieldView UITextField/UITextView object to unregister.
*/
-(void)removeTextFieldView:(UIView*)textFieldView;
/**
@method addResponderFromView
Add all the UITextField/UITextView responderView's.
@abstract Add all the UITextField/UITextView responderView's.
@param UIView object to register all it's responder subviews.
*/
-(void)addResponderFromView:(UIView*)view;
/**
@method removeResponderFromView
Remove all the UITextField/UITextView responderView's.
@abstract Remove all the UITextField/UITextView responderView's.
@param UIView object to unregister all it's responder subviews.
*/
-(void)removeResponderFromView:(UIView*)view;

View File

@@ -32,7 +32,10 @@
#import <UIKit/UITextView.h>
#import <UIKit/UITableView.h>
#import <UIKit/UIViewController.h>
#ifdef NSFoundationVersionNumber_iOS_5_1
#import <UIKit/UICollectionView.h>
#endif
NSString *const kIQTextField = @"kIQTextField";
NSString *const kIQTextFieldDelegate = @"kIQTextFieldDelegate";
@@ -41,6 +44,8 @@ NSString *const kIQTextFieldReturnKeyType = @"kIQTextFieldReturnKeyType";
@interface IQKeyboardReturnKeyHandler ()<UITextFieldDelegate,UITextViewDelegate>
-(void)updateReturnKeyTypeOnTextField:(UIView*)textField;
@end
@implementation IQKeyboardReturnKeyHandler
@@ -48,6 +53,10 @@ NSString *const kIQTextFieldReturnKeyType = @"kIQTextFieldReturnKeyType";
NSMutableSet *textFieldInfoCache;
}
@synthesize lastTextFieldReturnKeyType = _lastTextFieldReturnKeyType;
@synthesize toolbarManageBehaviour = _toolbarManageBehaviour;
@synthesize delegate = _delegate;
-(instancetype)initWithViewController:(UIViewController*)controller
{
self = [super init];
@@ -64,7 +73,7 @@ NSString *const kIQTextFieldReturnKeyType = @"kIQTextFieldReturnKeyType";
-(NSDictionary*)textFieldCachedInfo:(UITextField*)textField
{
for (NSDictionary *infoDict in textFieldInfoCache)
if (infoDict[kIQTextField] == textField) return infoDict;
if ([infoDict objectForKey:kIQTextField] == textField) return infoDict;
return nil;
}
@@ -90,9 +99,9 @@ NSString *const kIQTextFieldReturnKeyType = @"kIQTextFieldReturnKeyType";
if (dict)
{
textField.keyboardType = [dict[kIQTextFieldReturnKeyType] integerValue];
textField.delegate = dict[kIQTextFieldDelegate];
[textFieldInfoCache removeObject:textField];
textField.keyboardType = [[dict objectForKey:kIQTextFieldReturnKeyType] integerValue];
textField.delegate = [dict objectForKey:kIQTextFieldDelegate];
[textFieldInfoCache removeObject:dict];
}
}
@@ -100,10 +109,11 @@ NSString *const kIQTextFieldReturnKeyType = @"kIQTextFieldReturnKeyType";
{
NSMutableDictionary *dictInfo = [[NSMutableDictionary alloc] init];
dictInfo[kIQTextField] = textField;
dictInfo[kIQTextFieldReturnKeyType] = @([textField returnKeyType]);
[dictInfo setObject:textField forKey:kIQTextField];
[dictInfo setObject:[NSNumber numberWithInteger:textField.returnKeyType] forKey:kIQTextFieldReturnKeyType];
if (textField.delegate) dictInfo[kIQTextFieldDelegate] = textField.delegate;
if (textField.delegate) [dictInfo setObject:textField.delegate forKey:kIQTextFieldDelegate];
[textField setDelegate:self];
[textFieldInfoCache addObject:dictInfo];
@@ -116,7 +126,7 @@ NSString *const kIQTextFieldReturnKeyType = @"kIQTextFieldReturnKeyType";
for (NSDictionary *infoDict in textFieldInfoCache)
{
UITextField *textField = infoDict[kIQTextField];
UITextField *textField = [infoDict objectForKey:kIQTextField];
[self updateReturnKeyTypeOnTextField:textField];
}
@@ -125,7 +135,11 @@ NSString *const kIQTextFieldReturnKeyType = @"kIQTextFieldReturnKeyType";
-(void)updateReturnKeyTypeOnTextField:(UIView*)textField
{
UIView *tableView = [textField superviewOfClassType:[UITableView class]];
#ifdef NSFoundationVersionNumber_iOS_5_1
if (tableView == nil) tableView = [textField superviewOfClassType:[UICollectionView class]];
#endif
NSArray *textFields = nil;
@@ -166,7 +180,9 @@ NSString *const kIQTextFieldReturnKeyType = @"kIQTextFieldReturnKeyType";
-(void)goToNextResponderOrResign:(UIView*)textField
{
UIView *tableView = [textField superviewOfClassType:[UITableView class]];
#ifdef NSFoundationVersionNumber_iOS_5_1
if (tableView == nil) tableView = [textField superviewOfClassType:[UICollectionView class]];
#endif
NSArray *textFields = nil;
@@ -204,7 +220,7 @@ NSString *const kIQTextFieldReturnKeyType = @"kIQTextFieldReturnKeyType";
NSUInteger index = [textFields indexOfObject:textField];
//If it is not last textField. then it's next object becomeFirstResponder.
(index < textFields.count-1) ? [textFields[index+1] becomeFirstResponder] : [textField resignFirstResponder];
(index < textFields.count-1) ? [[textFields objectAtIndex:index+1] becomeFirstResponder] : [textField resignFirstResponder];
}
}
@@ -329,6 +345,8 @@ NSString *const kIQTextFieldReturnKeyType = @"kIQTextFieldReturnKeyType";
[self.delegate textViewDidChangeSelection:textView];
}
#ifdef NSFoundationVersionNumber_iOS_6_1
- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange
{
if ([self.delegate respondsToSelector:@selector(textView:shouldInteractWithURL:inRange:)])
@@ -345,13 +363,15 @@ NSString *const kIQTextFieldReturnKeyType = @"kIQTextFieldReturnKeyType";
return YES;
}
#endif
-(void)dealloc
{
for (NSDictionary *dict in textFieldInfoCache)
{
UITextField *textField = dict[kIQTextField];
textField.keyboardType = [dict[kIQTextFieldReturnKeyType] integerValue];
textField.delegate = dict[kIQTextFieldDelegate];
UITextField *textField = [dict objectForKey:kIQTextField];
textField.keyboardType = [[dict objectForKey:kIQTextFieldReturnKeyType] integerValue];
textField.delegate = [dict objectForKey:kIQTextFieldDelegate];
}
[textFieldInfoCache removeAllObjects];

View File

@@ -27,41 +27,34 @@
#import <UIKit/UISegmentedControl.h>
/**
@class IQSegmentedNextPrevious
@deprecated Deprecated in iOS 7
@abstract Custom SegmentedControl for Previous/Next button.
*/
#if !(__has_feature(objc_instancetype))
#define instancetype id
#endif
NS_CLASS_DEPRECATED_IOS(2_0, 7_0, "Deprecated for iOS 7")
/**
Custom SegmentedControl for Previous/Next button.
@deprecated Deprecated in iOS 7
*/
@interface IQSegmentedNextPrevious : UISegmentedControl
/**
@method initWithTarget:previousAction:nextAction:
Initialization function for IQSegmentedNextPrevious.
@abstract initialization function for IQSegmentedNextPrevious.
@param target: Target object for selector. Usually 'self'.
@param previousAction: Previous button action name. Usually 'previousAction:(IQSegmentedNextPrevious*)segmentedControl'.
@param nextAction: Next button action name. Usually 'nextAction:(IQSegmentedNextPrevious*)segmentedControl'.
@param target Target object for selector. Usually 'self'.
@param previousAction Previous button action name. Usually 'previousAction:(IQSegmentedNextPrevious*)segmentedControl'.
@param nextAction Next button action name. Usually 'nextAction:(IQSegmentedNextPrevious*)segmentedControl'.
*/
- (instancetype)initWithTarget:(id)target previousAction:(SEL)previousAction nextAction:(SEL)nextAction NS_DESIGNATED_INITIALIZER;
/**
@method init
@abstract initWithTarget:previousAction:nextAction should be used.
initWithTarget:previousAction:nextAction should be used.
*/
- (instancetype)init __attribute__((unavailable("init is not available, should use initWithTarget:previousAction:nextAction instead")));
/**
@method init
@abstract initWithTarget:previousAction:nextAction should be used.
initWithTarget:previousAction:nextAction should be used.
*/
+ (instancetype)new __attribute__((unavailable("new is not available, should use initWithTarget:previousAction:nextAction instead")));

View File

@@ -44,13 +44,16 @@
-(instancetype)initWithTarget:(id)target previousAction:(SEL)previousAction nextAction:(SEL)nextAction
{
// Creating it with two items, Previous/Next.
self = [super initWithItems:@[IQLocalizedString(@"Previous", nil),IQLocalizedString(@"Next", nil)]];
self = [super initWithItems:[NSArray arrayWithObjects:IQLocalizedString(@"Previous", nil),IQLocalizedString(@"Next", nil), nil]];
if (self)
{
if (IQ_IS_IOS7_OR_GREATER == NO)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
[self setSegmentedControlStyle:UISegmentedControlStyleBar];
#pragma GCC diagnostic pop
}
[self setMomentary:YES];

View File

@@ -26,16 +26,12 @@
#import <UIKit/UITextView.h>
/**
@class IQTextView
@abstract UITextView with placeholder support
UITextView with placeholder support
*/
@interface IQTextView : UITextView
/**
@property placeholder
@abstract To set textView's placeholder text. Default is ni.
Set textView's placeholder text. Default is nil.
*/
@property(nonatomic,copy) NSString *placeholder;

View File

@@ -26,6 +26,21 @@
#import <UIKit/UILabel.h>
#import <UIKit/UINibLoading.h>
#if !(__has_feature(objc_instancetype))
#define instancetype id
#endif
//Xcode 4.5 compatibility check
#ifndef NSFoundationVersionNumber_iOS_5_1
#define NSLineBreakByWordWrapping UILineBreakModeWordWrap
#endif
@interface IQTextView ()
-(void)refreshPlaceholder;
@end
@implementation IQTextView
{
UILabel *placeHolderLabel;

View File

@@ -25,11 +25,8 @@
#import <UIKit/UIBarButtonItem.h>
/**
@class IQBarButtonItem
@abstract IQBarButtonItem used for IQToolbar.
IQBarButtonItem used for IQToolbar.
*/
@interface IQBarButtonItem : UIBarButtonItem
@end

View File

@@ -24,28 +24,27 @@
#import <Foundation/NSObjCRuntime.h>
#import "IQKeyboardManagerConstants.h"
#import "IQBarButtonItem.h"
#if !(__has_feature(objc_instancetype))
#define instancetype id
#endif
/**
@author Iftekhar Qurashi
@related hack.iftekhar@gmail.com
@class IQTitleBarButtonItem
@abstract BarButtonItem with title text.
BarButtonItem with title text.
*/
@interface IQTitleBarButtonItem : IQBarButtonItem
/**
@property font
@abstract font to be used in bar button. Default is (system font 12.0 bold).
Font to be used in bar button. Default is (system font 12.0 bold).
*/
@property(nonatomic, strong) UIFont *font;
/**
@method initWithFrame:title:
Initialize with frame and title.
@abstract initialize with frame and title.
@param frame Initial frame of barButtonItem
@param title Title of barButtonItem.
*/
-(instancetype)initWithFrame:(CGRect)frame title:(NSString *)title NS_DESIGNATED_INITIALIZER;

View File

@@ -23,11 +23,16 @@
#import "IQTitleBarButtonItem.h"
#import "IQKeyboardManagerConstants.h"
#import "IQKeyboardManagerConstantsInternal.h"
#import <UIKit/UILabel.h>
#ifndef NSFoundationVersionNumber_iOS_5_1
#define NSTextAlignmentCenter UITextAlignmentCenter
#endif
@implementation IQTitleBarButtonItem
{
UIView *_titleView;
UILabel *_titleLabel;
}
@synthesize font = _font;
@@ -37,15 +42,29 @@
self = [super initWithTitle:nil style:UIBarButtonItemStylePlain target:nil action:nil];
if (self)
{
_titleLabel = [[UILabel alloc] initWithFrame:frame];
_titleView = [[UIView alloc] initWithFrame:frame];
_titleView.backgroundColor = [UIColor clearColor];
_titleView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
_titleLabel = [[UILabel alloc] initWithFrame:_titleView.bounds];
if (IQ_IS_IOS7_OR_GREATER)
{
[_titleLabel setTextColor:[UIColor lightGrayColor]];
}
else
{
[_titleLabel setTextColor:[UIColor whiteColor]];
}
[_titleLabel setBackgroundColor:[UIColor clearColor]];
[_titleLabel setTextAlignment:NSTextAlignmentCenter];
[_titleLabel setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[self setTitle:title];
[self setFont:[UIFont boldSystemFontOfSize:12.0]];
self.title = title;
[_titleView addSubview:_titleLabel];
self.customView = _titleLabel;
self.customView = _titleView;
self.enabled = NO;
}
return self;

View File

@@ -24,25 +24,19 @@
#import <UIKit/UIToolbar.h>
/**
@class IQToolbar
@abstract IQToolbar for IQKeyboardManager.
IQToolbar for IQKeyboardManager.
*/
@interface IQToolbar : UIToolbar <UIInputViewAudioFeedback>
/**
@property titleFont
@abstract title font for toolbar.
Title font for toolbar.
*/
@property(nonatomic, strong) UIFont *titleFont;
@property(nonatomic, strong) UIFont *titleFont;
/**
@property title
@abstract toolbar title
Toolbar title
*/
@property(nonatomic, strong) NSString *title;
@property(nonatomic, strong) NSString *title;
@end

View File

@@ -28,19 +28,28 @@
#import <UIKit/UIViewController.h>
#if !(__has_feature(objc_instancetype))
#define instancetype id
#endif
@implementation IQToolbar
@synthesize titleFont = _titleFont;
@synthesize title = _title;
+(void)initialize
{
[super initialize];
[[self appearance] setTintColor:nil];
#ifdef NSFoundationVersionNumber_iOS_6_1
if ([[self appearance] respondsToSelector:@selector(setBarTintColor:)])
{
[[self appearance] setBarTintColor:nil];
}
#endif
[[self appearance] setBackgroundColor:nil];
}

View File

@@ -27,140 +27,277 @@
@class UIBarButtonItem;
/**
@category UIView (IQToolbarAddition)
@abstract UIView category methods to add IQToolbar on UIKeyboard.
UIView category methods to add IQToolbar on UIKeyboard.
*/
@interface UIView (IQToolbarAddition)
/**
@property shouldHideTitle
@abstract if shouldHideTitle is YES, then title will not be added to the toolbar. Default to NO.
If shouldHideTitle is YES, then title will not be added to the toolbar. Default to NO.
*/
@property (assign, nonatomic) BOOL shouldHideTitle;
///-----------------------------------------
/// @name Customised Invocation Registration
///-----------------------------------------
/**
@method setCustomPreviousTarget:action:
@method setCustomNextTarget:action:
@method setCustomDoneTarget:action:
Additional target & action to do get callback action. Note that setting custom `previous` selector doesn't affect native `previous` functionality, this is just used to notifiy user to do additional work according to need.
@abstract Invoke action on target when the toolbar is created using IQKeyboardManager, you may add additional target & action to do get callback action. Note that setting custom previous/next/done selector doesn't affect native next/previous/done functionality, this is just used to notifiy user to do additional work according to your need.
@param target Target object.
@param action Target Selector.
*/
-(void)setCustomPreviousTarget:(id)target action:(SEL)action;
/**
Additional target & action to do get callback action. Note that setting custom `next` selector doesn't affect native `next` functionality, this is just used to notifiy user to do additional work according to need.
@param target Target object.
@param action Target Selector.
*/
-(void)setCustomNextTarget:(id)target action:(SEL)action;
/**
Additional target & action to do get callback action. Note that setting custom `done` selector doesn't affect native `done` functionality, this is just used to notifiy user to do additional work according to need.
@param target Target object.
@param action Target Selector.
*/
-(void)setCustomDoneTarget:(id)target action:(SEL)action;
/**
@property previousInvocation
@abstract customized Invocation to be called on previous arrow action. previousInvocation is internally created using setCustomPreviousTarget: method.
Customized Invocation to be called on previous arrow action. previousInvocation is internally created using setCustomPreviousTarget: method.
*/
@property (strong, nonatomic) NSInvocation *previousInvocation;
/**
@property nextInvocation
@abstract customized Invocation to be called on next arrow action. nextInvocation is internally created using setCustomNextTarget: method.
Customized Invocation to be called on next arrow action. nextInvocation is internally created using setCustomNextTarget: method.
*/
@property (strong, nonatomic) NSInvocation *nextInvocation;
/**
@property nextInvocation
@abstract customized Invocation to be called on done action. doneInvocation is internally created using setCustomDoneTarget: method.
Customized Invocation to be called on done action. doneInvocation is internally created using setCustomDoneTarget: method.
*/
@property (strong, nonatomic) NSInvocation *doneInvocation;
///------------
/// @name Done
///------------
/**
@method addDoneOnKeyboardWithTarget:action:
@method addDoneOnKeyboardWithTarget:action:titleText:
@method addDoneOnKeyboardWithTarget:action:shouldShowPlaceholder:
@method addRightButtonOnKeyboardWithText:target:action:
@method addRightButtonOnKeyboardWithText:target:action:titleText:
@method addRightButtonOnKeyboardWithText:target:action:shouldShowPlaceholder:
Helper function to add Done button on keyboard.
@abstract Helper functions to add Done button on keyboard.
@param target: Target object for selector. Usually 'self'.
@param action: Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param shouldShowPlaceholder: A boolean to indicate whether to show textField placeholder on IQToolbar'.
@param titleText: text to show as title in IQToolbar'.
@param target Target object for selector.
@param action Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
*/
- (void)addDoneOnKeyboardWithTarget:(id)target action:(SEL)action;
- (void)addDoneOnKeyboardWithTarget:(id)target action:(SEL)action titleText:(NSString*)titleText;
- (void)addDoneOnKeyboardWithTarget:(id)target action:(SEL)action shouldShowPlaceholder:(BOOL)showPlaceholder;
- (void)addRightButtonOnKeyboardWithText:(NSString*)text target:(id)target action:(SEL)action;
- (void)addRightButtonOnKeyboardWithText:(NSString*)text target:(id)target action:(SEL)action titleText:(NSString*)titleText;
- (void)addRightButtonOnKeyboardWithText:(NSString*)text target:(id)target action:(SEL)action shouldShowPlaceholder:(BOOL)showPlaceholder;
/**
@method addCancelDoneOnKeyboardWithTarget:cancelAction:doneAction:
@method addCancelDoneOnKeyboardWithTarget:cancelAction:doneAction:titleText:
@method addCancelDoneOnKeyboardWithTarget:cancelAction:doneAction:shouldShowPlaceholder:
@method addLeftRightOnKeyboardWithTarget:leftButtonTitle:rightButtonTitle:leftButtonAction:rightButtonAction
@method addLeftRightOnKeyboardWithTarget:leftButtonTitle:rightButtonTitle:leftButtonAction:rightButtonAction:titleText:
@method addLeftRightOnKeyboardWithTarget:leftButtonTitle:rightButtonTitle:leftButtonAction:rightButtonAction:shouldShowPlaceholder:
Helper function to add Done button on keyboard.
@abstract Helper function to add Cancel and Done button on keyboard.
@param target Target object for selector.
@param action Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param titleText text to show as title in IQToolbar'.
*/
- (void)addDoneOnKeyboardWithTarget:(id)target action:(SEL)action titleText:(NSString*)titleText;
/**
Helper function to add Done button on keyboard.
@param target: Target object for selector. Usually 'self'.
@param target Target object for selector.
@param action Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param shouldShowPlaceholder A boolean to indicate whether to show textField placeholder on IQToolbar'.
*/
- (void)addDoneOnKeyboardWithTarget:(id)target action:(SEL)action shouldShowPlaceholder:(BOOL)shouldShowPlaceholder;
///------------
/// @name Right
///------------
/**
Helper function to add Right button on keyboard.
@param cancelAction: Crevious button action name. Usually 'cancelAction:(IQBarButtonItem*)item'.
@param text Title for rightBarButtonItem, usually 'Done'.
@param target Target object for selector.
@param action Right button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
*/
- (void)addRightButtonOnKeyboardWithText:(NSString*)text target:(id)target action:(SEL)action;
/**
Helper function to add Right button on keyboard.
@param doneAction: Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param text Title for rightBarButtonItem, usually 'Done'.
@param target Target object for selector.
@param action Right button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param titleText text to show as title in IQToolbar'.
*/
- (void)addRightButtonOnKeyboardWithText:(NSString*)text target:(id)target action:(SEL)action titleText:(NSString*)titleText;
/**
Helper function to add Right button on keyboard.
@param shouldShowPlaceholder: A boolean to indicate whether to show textField placeholder on IQToolbar'.
@param text Title for rightBarButtonItem, usually 'Done'.
@param target Target object for selector.
@param action Right button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param shouldShowPlaceholder A boolean to indicate whether to show textField placeholder on IQToolbar'.
*/
- (void)addRightButtonOnKeyboardWithText:(NSString*)text target:(id)target action:(SEL)action shouldShowPlaceholder:(BOOL)shouldShowPlaceholder;
///------------------
/// @name Cancel/Done
///------------------
/**
Helper function to add Cancel and Done button on keyboard.
@param titleText: text to show as title in IQToolbar'.
@param target Target object for selector.
@param cancelAction Cancel button action name. Usually 'cancelAction:(IQBarButtonItem*)item'.
@param doneAction Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
*/
- (void)addCancelDoneOnKeyboardWithTarget:(id)target cancelAction:(SEL)cancelAction doneAction:(SEL)doneAction;
- (void)addCancelDoneOnKeyboardWithTarget:(id)target cancelAction:(SEL)cancelAction doneAction:(SEL)doneAction titleText:(NSString*)titleText;
- (void)addCancelDoneOnKeyboardWithTarget:(id)target cancelAction:(SEL)cancelAction doneAction:(SEL)doneAction shouldShowPlaceholder:(BOOL)showPlaceholder;
- (void)addLeftRightOnKeyboardWithTarget:(id)target leftButtonTitle:(NSString*)leftTitle rightButtonTitle:(NSString*)rightTitle leftButtonAction:(SEL)leftAction rightButtonAction:(SEL)rightAction;
- (void)addLeftRightOnKeyboardWithTarget:(id)target leftButtonTitle:(NSString*)leftTitle rightButtonTitle:(NSString*)rightTitle leftButtonAction:(SEL)leftAction rightButtonAction:(SEL)rightAction titleText:(NSString*)titleText;
- (void)addLeftRightOnKeyboardWithTarget:(id)target leftButtonTitle:(NSString*)leftTitle rightButtonTitle:(NSString*)rightTitle leftButtonAction:(SEL)leftAction rightButtonAction:(SEL)rightAction shouldShowPlaceholder:(BOOL)showPlaceholder;
/**
@method addPreviousNextDoneOnKeyboardWithTarget:previousAction:nextAction:doneAction
@method addPreviousNextDoneOnKeyboardWithTarget:previousAction:nextAction:doneAction:titleText:
@method addPreviousNextDoneOnKeyboardWithTarget:previousAction:nextAction:doneAction:shouldShowPlaceholder:
@method addPreviousNextRightOnKeyboardWithTarget:rightButtonTitle:previousAction:nextAction:rightButtonAction
@method addPreviousNextRightOnKeyboardWithTarget:rightButtonTitle:previousAction:nextAction:rightButtonAction:titleText:
@method addPreviousNextRightOnKeyboardWithTarget:rightButtonTitle:previousAction:nextAction:rightButtonAction:shouldShowPlaceholder:
Helper function to add Cancel and Done button on keyboard.
@abstract Helper function to add SegmentedNextPrevious and Done button on keyboard.
@param target Target object for selector.
@param cancelAction Cancel button action name. Usually 'cancelAction:(IQBarButtonItem*)item'.
@param doneAction Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param titleText text to show as title in IQToolbar'.
*/
- (void)addCancelDoneOnKeyboardWithTarget:(id)target cancelAction:(SEL)cancelAction doneAction:(SEL)doneAction titleText:(NSString*)titleText;
/**
Helper function to add Cancel and Done button on keyboard.
@param target: Target object for selector. Usually 'self'.
@param target Target object for selector.
@param cancelAction Cancel button action name. Usually 'cancelAction:(IQBarButtonItem*)item'.
@param doneAction Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param shouldShowPlaceholder A boolean to indicate whether to show textField placeholder on IQToolbar'.
*/
- (void)addCancelDoneOnKeyboardWithTarget:(id)target cancelAction:(SEL)cancelAction doneAction:(SEL)doneAction shouldShowPlaceholder:(BOOL)shouldShowPlaceholder;
///-----------------
/// @name Right/Left
///-----------------
/**
Helper function to add Left and Right button on keyboard.
@param previousAction: Previous button action name. Usually 'previousAction:(IQSegmentedNextPrevious*)segmentedControl'.
@param target Target object for selector.
@param leftButtonTitle Title for leftBarButtonItem, usually 'Cancel'.
@param rightButtonTitle Title for rightBarButtonItem, usually 'Done'.
@param leftButtonAction Left button action name. Usually 'cancelAction:(IQBarButtonItem*)item'.
@param rightButtonAction Right button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
*/
- (void)addLeftRightOnKeyboardWithTarget:(id)target leftButtonTitle:(NSString*)leftButtonTitle rightButtonTitle:(NSString*)rightButtonTitle leftButtonAction:(SEL)leftButtonAction rightButtonAction:(SEL)rightButtonAction;
/**
Helper function to add Left and Right button on keyboard.
@param nextAction: Next button action name. Usually 'nextAction:(IQSegmentedNextPrevious*)segmentedControl'.
@param target Target object for selector.
@param leftButtonTitle Title for leftBarButtonItem, usually 'Cancel'.
@param rightButtonTitle Title for rightBarButtonItem, usually 'Done'.
@param leftButtonAction Left button action name. Usually 'cancelAction:(IQBarButtonItem*)item'.
@param rightButtonAction Right button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param titleText text to show as title in IQToolbar'.
*/
- (void)addLeftRightOnKeyboardWithTarget:(id)target leftButtonTitle:(NSString*)leftButtonTitle rightButtonTitle:(NSString*)rightButtonTitle leftButtonAction:(SEL)leftButtonAction rightButtonAction:(SEL)rightButtonAction titleText:(NSString*)titleText;
/**
Helper function to add Left and Right button on keyboard.
@param doneAction: Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param target Target object for selector.
@param leftButtonTitle Title for leftBarButtonItem, usually 'Cancel'.
@param rightButtonTitle Title for rightBarButtonItem, usually 'Done'.
@param leftButtonAction Left button action name. Usually 'cancelAction:(IQBarButtonItem*)item'.
@param rightButtonAction Right button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param shouldShowPlaceholder A boolean to indicate whether to show textField placeholder on IQToolbar'.
*/
- (void)addLeftRightOnKeyboardWithTarget:(id)target leftButtonTitle:(NSString*)leftButtonTitle rightButtonTitle:(NSString*)rightButtonTitle leftButtonAction:(SEL)leftButtonAction rightButtonAction:(SEL)rightButtonAction shouldShowPlaceholder:(BOOL)shouldShowPlaceholder;
///-------------------------
/// @name Previous/Next/Done
///-------------------------
/**
Helper function to add SegmentedNextPrevious/ArrowNextPrevious and Done button on keyboard.
@param shouldShowPlaceholder: A boolean to indicate whether to show textField placeholder on IQToolbar'.
@param titleText: text to show as title in IQToolbar'.
@param target Target object for selector.
@param previousAction Previous button action name. Usually 'previousAction:(id)item'.
@param nextAction Next button action name. Usually 'nextAction:(id)item'.
@param doneAction Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
*/
- (void)addPreviousNextDoneOnKeyboardWithTarget:(id)target previousAction:(SEL)previousAction nextAction:(SEL)nextAction doneAction:(SEL)doneAction;
- (void)addPreviousNextDoneOnKeyboardWithTarget:(id)target previousAction:(SEL)previousAction nextAction:(SEL)nextAction doneAction:(SEL)doneAction titleText:(NSString*)titleText;
- (void)addPreviousNextDoneOnKeyboardWithTarget:(id)target previousAction:(SEL)previousAction nextAction:(SEL)nextAction doneAction:(SEL)doneAction shouldShowPlaceholder:(BOOL)showPlaceholder;
- (void)addPreviousNextRightOnKeyboardWithTarget:(id)target rightButtonTitle:(NSString*)rightButtonTitle previousAction:(SEL)previousAction nextAction:(SEL)nextAction rightButtonAction:(SEL)rightButtonAction;
- (void)addPreviousNextRightOnKeyboardWithTarget:(id)target rightButtonTitle:(NSString*)rightButtonTitle previousAction:(SEL)previousAction nextAction:(SEL)nextAction rightButtonAction:(SEL)rightButtonAction titleText:(NSString*)titleText;
- (void)addPreviousNextRightOnKeyboardWithTarget:(id)target rightButtonTitle:(NSString*)rightButtonTitle previousAction:(SEL)previousAction nextAction:(SEL)nextAction rightButtonAction:(SEL)rightButtonAction shouldShowPlaceholder:(BOOL)showPlaceholder;
/**
@method setEnablePrevious:next:
Helper function to add SegmentedNextPrevious/ArrowNextPrevious and Done button on keyboard.
@abstract Helper function to enable and disable previous next buttons.
@param target Target object for selector.
@param previousAction Previous button action name. Usually 'previousAction:(id)item'.
@param nextAction Next button action name. Usually 'nextAction:(id)item'.
@param doneAction Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param titleText text to show as title in IQToolbar'.
*/
- (void)addPreviousNextDoneOnKeyboardWithTarget:(id)target previousAction:(SEL)previousAction nextAction:(SEL)nextAction doneAction:(SEL)doneAction titleText:(NSString*)titleText;
/**
Helper function to add SegmentedNextPrevious/ArrowNextPrevious and Done button on keyboard.
@param isPreviousEnabled: BOOL to enable/disable previous button on keyboard.
@param target Target object for selector.
@param previousAction Previous button action name. Usually 'previousAction:(id)item'.
@param nextAction Next button action name. Usually 'nextAction:(id)item'.
@param doneAction Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param shouldShowPlaceholder A boolean to indicate whether to show textField placeholder on IQToolbar'.
*/
- (void)addPreviousNextDoneOnKeyboardWithTarget:(id)target previousAction:(SEL)previousAction nextAction:(SEL)nextAction doneAction:(SEL)doneAction shouldShowPlaceholder:(BOOL)shouldShowPlaceholder;
///--------------------------
/// @name Previous/Next/Right
///--------------------------
/**
Helper function to add SegmentedNextPrevious/ArrowNextPrevious and Right button on keyboard.
@param isNextEnabled: BOOL to enable/disable next button on keyboard..
@param target Target object for selector.
@param rightButtonTitle Title for rightBarButtonItem, usually 'Done'.
@param previousAction Previous button action name. Usually 'previousAction:(id)item'.
@param nextAction Next button action name. Usually 'nextAction:(id)item'.
@param rightButtonAction RightBarButton action name. Usually 'doneAction:(IQBarButtonItem*)item'.
*/
- (void)addPreviousNextRightOnKeyboardWithTarget:(id)target rightButtonTitle:(NSString*)rightButtonTitle previousAction:(SEL)previousAction nextAction:(SEL)nextAction rightButtonAction:(SEL)rightButtonAction;
/**
Helper function to add SegmentedNextPrevious/ArrowNextPrevious and Right button on keyboard.
@param target Target object for selector.
@param rightButtonTitle Title for rightBarButtonItem, usually 'Done'.
@param previousAction Previous button action name. Usually 'previousAction:(id)item'.
@param nextAction Next button action name. Usually 'nextAction:(id)item'.
@param rightButtonAction RightBarButton action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param titleText text to show as title in IQToolbar'.
*/
- (void)addPreviousNextRightOnKeyboardWithTarget:(id)target rightButtonTitle:(NSString*)rightButtonTitle previousAction:(SEL)previousAction nextAction:(SEL)nextAction rightButtonAction:(SEL)rightButtonAction titleText:(NSString*)titleText;
/**
Helper function to add SegmentedNextPrevious/ArrowNextPrevious and Right button on keyboard.
@param target Target object for selector.
@param rightButtonTitle Title for rightBarButtonItem, usually 'Done'.
@param previousAction Previous button action name. Usually 'previousAction:(id)item'.
@param nextAction Next button action name. Usually 'nextAction:(id)item'.
@param rightButtonAction RightBarButton action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param shouldShowPlaceholder A boolean to indicate whether to show textField placeholder on IQToolbar'.
*/
- (void)addPreviousNextRightOnKeyboardWithTarget:(id)target rightButtonTitle:(NSString*)rightButtonTitle previousAction:(SEL)previousAction nextAction:(SEL)nextAction rightButtonAction:(SEL)rightButtonAction shouldShowPlaceholder:(BOOL)shouldShowPlaceholder;
///-----------------------------------
/// @name Enable/Disable Previous/Next
///-----------------------------------
/**
Helper function to enable and disable previous next buttons.
@param isPreviousEnabled BOOL to enable/disable previous button on keyboard.
@param isNextEnabled BOOL to enable/disable next button on keyboard..
*/
- (void)setEnablePrevious:(BOOL)isPreviousEnabled next:(BOOL)isNextEnabled;

View File

@@ -38,7 +38,7 @@
-(void)setShouldHideTitle:(BOOL)shouldHideTitle
{
objc_setAssociatedObject(self, @selector(shouldHideTitle), @(shouldHideTitle), OBJC_ASSOCIATION_ASSIGN);
objc_setAssociatedObject(self, @selector(shouldHideTitle), [NSNumber numberWithBool:shouldHideTitle], OBJC_ASSOCIATION_ASSIGN);
}
-(BOOL)shouldHideTitle
@@ -108,6 +108,8 @@
}
#pragma mark - Toolbar on UIKeyboard
- (void)addRightButtonOnKeyboardWithText:(NSString*)text target:(id)target action:(SEL)action titleText:(NSString*)titleText
{
// If can't set InputAccessoryView. Then return
@@ -115,7 +117,7 @@
// Creating a toolBar for keyboard
IQToolbar *toolbar = [[IQToolbar alloc] init];
if ([self respondsToSelector:@selector(keyboardAppearance)])
if (IQ_IS_IOS7_OR_GREATER && [self respondsToSelector:@selector(keyboardAppearance)])
{
switch ([(UITextField*)self keyboardAppearance])
{
@@ -141,10 +143,10 @@
else
{
/*
57 done button frame.
8 distance maintenance
64 done button frame.
16 distance maintenance
*/
buttonFrame = CGRectMake(0, 0, toolbar.frame.size.width-57.0-8, 44);
buttonFrame = CGRectMake(0, 0, toolbar.frame.size.width-64.0-16, 44);
}
IQTitleBarButtonItem *title = [[IQTitleBarButtonItem alloc] initWithFrame:buttonFrame title:titleText];
@@ -188,7 +190,7 @@
// Creating a toolBar for keyboard
IQToolbar *toolbar = [[IQToolbar alloc] init];
if ([self respondsToSelector:@selector(keyboardAppearance)])
if (IQ_IS_IOS7_OR_GREATER && [self respondsToSelector:@selector(keyboardAppearance)])
{
switch ([(UITextField*)self keyboardAppearance])
{
@@ -214,10 +216,10 @@
else
{
/*
57 done button frame.
8 distance maintenance
64 done button frame.
16 distance maintenance
*/
buttonFrame = CGRectMake(0, 0, toolbar.frame.size.width-57.0-8, 44);
buttonFrame = CGRectMake(0, 0, toolbar.frame.size.width-64.0-16, 44);
}
IQTitleBarButtonItem *title = [[IQTitleBarButtonItem alloc] initWithFrame:buttonFrame title:titleText];
@@ -239,8 +241,6 @@
[(UITextField*)self setInputAccessoryView:toolbar];
}
#pragma mark - Toolbar on UIKeyboard
-(void)addDoneOnKeyboardWithTarget:(id)target action:(SEL)action shouldShowPlaceholder:(BOOL)showPlaceholder
{
NSString *title;
@@ -262,7 +262,7 @@
// Creating a toolBar for keyboard
IQToolbar *toolbar = [[IQToolbar alloc] init];
if ([self respondsToSelector:@selector(keyboardAppearance)])
if (IQ_IS_IOS7_OR_GREATER && [self respondsToSelector:@selector(keyboardAppearance)])
{
switch ([(UITextField*)self keyboardAppearance])
{
@@ -340,7 +340,7 @@
// Creating a toolBar for keyboard
IQToolbar *toolbar = [[IQToolbar alloc] init];
if ([self respondsToSelector:@selector(keyboardAppearance)])
if (IQ_IS_IOS7_OR_GREATER && [self respondsToSelector:@selector(keyboardAppearance)])
{
switch ([(UITextField*)self keyboardAppearance])
{
@@ -418,7 +418,7 @@
// Creating a toolBar for phoneNumber keyboard
IQToolbar *toolbar = [[IQToolbar alloc] init];
if ([self respondsToSelector:@selector(keyboardAppearance)])
if (IQ_IS_IOS7_OR_GREATER && [self respondsToSelector:@selector(keyboardAppearance)])
{
switch ([(UITextField*)self keyboardAppearance])
{
@@ -441,7 +441,7 @@
UIImage *imageRightArrow;
//Xcode Compilation check
#if IQ_IS_XCODE_6_0_OR_GREATER
#ifdef NSFoundationVersionNumber_iOS_7_1
if (IQ_IS_IOS8_OR_GREATER)
{
@@ -501,10 +501,10 @@
{
/*
135 next/previous maximum x.
57 done button frame.
64 done button frame.
8+8 distance maintenance
*/
buttonFrame = CGRectMake(0, 0, toolbar.frame.size.width-135-57.0-16, 44);
buttonFrame = CGRectMake(0, 0, toolbar.frame.size.width-135-64.0-16, 44);
}
IQTitleBarButtonItem *title = [[IQTitleBarButtonItem alloc] initWithFrame:buttonFrame title:titleText];
@@ -544,7 +544,7 @@
// Creating a toolBar for phoneNumber keyboard
IQToolbar *toolbar = [[IQToolbar alloc] init];
if ([self respondsToSelector:@selector(keyboardAppearance)])
if (IQ_IS_IOS7_OR_GREATER && [self respondsToSelector:@selector(keyboardAppearance)])
{
switch ([(UITextField*)self keyboardAppearance])
{
@@ -567,7 +567,7 @@
UIImage *imageRightArrow;
//Xcode Compilation check
#if IQ_IS_XCODE_6_0_OR_GREATER
#ifdef NSFoundationVersionNumber_iOS_7_1
if (IQ_IS_IOS8_OR_GREATER)
{
@@ -627,10 +627,10 @@
{
/*
135 next/previous maximum x.
57 done button frame.
64 done button frame.
8+8 distance maintenance
*/
buttonFrame = CGRectMake(0, 0, toolbar.frame.size.width-135-57.0-16, 44);
buttonFrame = CGRectMake(0, 0, toolbar.frame.size.width-135-64.0-16, 44);
}
IQTitleBarButtonItem *title = [[IQTitleBarButtonItem alloc] initWithFrame:buttonFrame title:titleText];
@@ -674,8 +674,8 @@
if (IQ_IS_IOS7_OR_GREATER && [[inputAccessoryView items] count]>3)
{
// Getting first item from inputAccessoryView.
IQBarButtonItem *prevButton = (IQBarButtonItem*)[inputAccessoryView items][0];
IQBarButtonItem *nextButton = (IQBarButtonItem*)[inputAccessoryView items][2];
IQBarButtonItem *prevButton = (IQBarButtonItem*)[[inputAccessoryView items] objectAtIndex:0];
IQBarButtonItem *nextButton = (IQBarButtonItem*)[[inputAccessoryView items] objectAtIndex:2];
// If it is UIBarButtonItem and it's customView is not nil.
if ([prevButton isKindOfClass:[IQBarButtonItem class]] && [nextButton isKindOfClass:[IQBarButtonItem class]])
@@ -689,7 +689,7 @@
else
{
// Getting first item from inputAccessoryView.
IQBarButtonItem *barButtonItem = (IQBarButtonItem*)[inputAccessoryView items][0];
IQBarButtonItem *barButtonItem = (IQBarButtonItem*)[[inputAccessoryView items] objectAtIndex:0];
// If it is IQBarButtonItem and it's customView is not nil.
if ([barButtonItem isKindOfClass:[IQBarButtonItem class]] && [barButtonItem customView] != nil)

View File

@@ -149,7 +149,7 @@ class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextViewDele
textView.delegate = dict[kIQTextFieldDelegate] as UITextViewDelegate?
}
textFieldInfoCache.removeObject(view)
textFieldInfoCache.removeObject(dict)
}
}

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6751" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="En3-R6-bks">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6751" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="En3-R6-bks">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6736"/>
@@ -1549,7 +1549,7 @@ textField.inputAcessoryView = [[UIView alloc] init];</string>
</connections>
</searchBar>
<view contentMode="scaleToFill" id="SHK-82-xFg">
<rect key="frame" x="10" y="161" width="305" height="269.99999959484421"/>
<rect key="frame" x="10" y="161" width="305" height="269.99999927972311"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" id="k8L-Hj-hKb">
@@ -1588,7 +1588,7 @@ textField.inputAcessoryView = [[UIView alloc] init];</string>
<color key="backgroundColor" red="0.80000001192092896" green="1" blue="0.40000000596046448" alpha="1" colorSpace="calibratedRGB"/>
</view>
<view contentMode="scaleToFill" id="uYv-to-iCC">
<rect key="frame" x="10" y="170" width="285" height="89.999999859753771"/>
<rect key="frame" x="10" y="169.99999952904975" width="285" height="90"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" heightSizable="YES"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" tag="102" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="TextField 4" minimumFontSize="17" id="yDj-sx-3pn">

View File

@@ -8,6 +8,10 @@
#import <UIKit/UIKit.h>
#ifdef NSFoundationVersionNumber_iOS_5_1
@interface CollectionViewDemoController : UIViewController
@end
#endif

View File

@@ -8,6 +8,8 @@
#import "CollectionViewDemoController.h"
#ifdef NSFoundationVersionNumber_iOS_5_1
@interface CollectionViewDemoController ()<UICollectionViewDelegate>
@end
@@ -36,3 +38,5 @@
}
@end
#endif

View File

@@ -24,6 +24,10 @@
#import <UIKit/UIKit.h>
#if !(__has_feature(objc_instancetype))
#define instancetype id
#endif
/**
@enum IQDropDownMode
@@ -36,15 +40,25 @@
@const IQDropDownModeDatePicker Show UIDatePicker to pick date.
*/
typedef NS_ENUM(NSInteger, IQDropDownMode) {
#ifndef NS_ENUM
typedef enum IQDropDownMode {
IQDropDownModeTextPicker,
IQDropDownModeTimePicker,
IQDropDownModeDatePicker,
}IQDropDownMode;
#else
typedef NS_ENUM(NSInteger, IQDropDownMode) {
IQDropDownModeTextPicker,
IQDropDownModeTimePicker,
IQDropDownModeDatePicker,
};
#endif
@class IQDropDownTextField;
/**

View File

@@ -24,6 +24,11 @@
#import "IQDropDownTextField.h"
#ifndef NSFoundationVersionNumber_iOS_5_1
#define NSTextAlignmentCenter UITextAlignmentCenter
#endif
@interface IQDropDownTextField () <UIPickerViewDelegate, UIPickerViewDataSource>
{
NSArray *_ItemListsInternal;
@@ -35,10 +40,25 @@
@property (nonatomic, strong) NSDateFormatter *dropDownDateFormatter;
@property (nonatomic, strong) NSDateFormatter *dropDownTimeFormatter;
- (void)dateChanged:(UIDatePicker *)dPicker;
- (void)timeChanged:(UIDatePicker *)tPicker;
@end
@implementation IQDropDownTextField
@synthesize dropDownMode = _dropDownMode;
@synthesize itemList = _itemList;
@synthesize selectedItem = _selectedItem;
@synthesize isOptionalDropDown = _isOptionalDropDown;
@synthesize datePickerMode = _datePickerMode;
@synthesize minimumDate = _minimumDate;
@synthesize maximumDate = _maximumDate;
@synthesize delegate;
@synthesize pickerView,datePicker, timePicker, dropDownDateFormatter,dropDownTimeFormatter;
@synthesize dateFormatter, timeFormatter;
#pragma mark - Initialization
- (void)initialize
@@ -129,7 +149,7 @@
UILabel *labelText = [[UILabel alloc] init];
[labelText setTextAlignment:NSTextAlignmentCenter];
[labelText setAdjustsFontSizeToFitWidth:YES];
[labelText setText:_ItemListsInternal[row]];
[labelText setText:[_ItemListsInternal objectAtIndex:row]];
labelText.backgroundColor = [UIColor clearColor];
if (self.isOptionalDropDown && row == 0)
@@ -147,7 +167,7 @@
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
[self setSelectedItem:_ItemListsInternal[row]];
[self setSelectedItem:[_ItemListsInternal objectAtIndex:row]];
}
#pragma mark - UIDatePicker delegate
@@ -191,7 +211,7 @@
}
else
{
self.text = _ItemListsInternal[row];
self.text = [_ItemListsInternal objectAtIndex:row];
}
[self.pickerView selectRow:row inComponent:0 animated:animated];
@@ -384,7 +404,7 @@
if (_isOptionalDropDown)
{
NSArray *array = @[@"Select"];
NSArray *array = [NSArray arrayWithObject:@"Select"];
_ItemListsInternal = [array arrayByAddingObjectsFromArray:_itemList];
}
else
@@ -399,7 +419,7 @@
-(NSDateComponents *)dateComponents
{
return [[NSCalendar currentCalendar] components:NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear fromDate:self.date];
return [[NSCalendar currentCalendar] components:kCFCalendarUnitDay | kCFCalendarUnitMonth | kCFCalendarUnitYear fromDate:self.date];
}
- (NSInteger)year { return [[self dateComponents] year]; }

View File

@@ -12,6 +12,12 @@
@interface ManualToolbarViewController ()
-(void)previousAction:(id)sender;
-(void)nextAction:(id)sender;
-(void)doneAction:(id)sender;
@end
@implementation ManualToolbarViewController

View File

@@ -9,6 +9,7 @@
#import "NavigationTableViewCell.h"
@implementation NavigationTableViewCell
@synthesize labelTitle, labelSubtitle;
- (void)awakeFromNib
{

View File

@@ -9,6 +9,7 @@
#import "OptionTableViewCell.h"
@implementation OptionTableViewCell
@synthesize labelOption;
- (void)awakeFromNib
{

View File

@@ -15,6 +15,8 @@
@implementation OptionsViewController
@synthesize delegate, options, selectedIndex;
- (void)viewDidLoad
{
[super viewDidLoad];
@@ -27,9 +29,9 @@
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
OptionTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([OptionTableViewCell class]) forIndexPath:indexPath];
OptionTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([OptionTableViewCell class])];
cell.labelOption.text = self.options[indexPath.row];
cell.labelOption.text = [self.options objectAtIndex:indexPath.row];
cell.accessoryType = (indexPath.row == self.selectedIndex) ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;

View File

@@ -33,32 +33,33 @@
{
[super viewDidLoad];
sectionTitles = @[@"UIKeyboard Handling",
sectionTitles = [NSArray arrayWithObjects:@"UIKeyboard Handling",
@"IQToolbar handling",
@"UITextView handling",
@"Keyboard appearance overriding",
@"Resign first responder handling",
@"Sound handling",
@"Animation handling"];
@"Animation handling",nil];
keyboardManagerProperties = @[@[@"Enable", @"Keyboard Distance From TextField", @"Prevent Showing Bottom Blank Space"],
@[@"Enable Auto Toolbar",@"Toolbar Manage Behaviour",@"Should Toolbar Uses TextField TintColor",@"Should Show TextField Placeholder",@"Placeholder Font"],
@[@"Can Adjust TextView"],
@[@"Override Keyboard Appearance",@"Keyboard Appearance"],
@[@"Should Resign On Touch Outside"],
@[@"Should Play Input Clicks"],
@[@"Should Adopt Default Keyboard Animation"],
];
keyboardManagerProperties = [NSArray arrayWithObjects:
[NSArray arrayWithObjects:@"Enable", @"Keyboard Distance From TextField", @"Prevent Showing Bottom Blank Space",nil],
[NSArray arrayWithObjects:@"Enable Auto Toolbar",@"Toolbar Manage Behaviour",@"Should Toolbar Uses TextField TintColor",@"Should Show TextField Placeholder",@"Placeholder Font",nil],
[NSArray arrayWithObjects:@"Can Adjust TextView",nil],
[NSArray arrayWithObjects:@"Override Keyboard Appearance",@"Keyboard Appearance",nil],
[NSArray arrayWithObjects:@"Should Resign On Touch Outside",nil],
[NSArray arrayWithObjects:@"Should Play Input Clicks",nil],
[NSArray arrayWithObjects:@"Should Adopt Default Keyboard Animation",nil],nil];
keyboardManagerPropertyDetails = @[@[@"Enable/Disable IQKeyboardManager",@"Set keyboard distance from textField",@"Prevent to show blank space between UIKeyboard and View"],
@[@"Automatic add the IQToolbar on UIKeyboard",@"AutoToolbar previous/next button managing behaviour",@"Uses textField's tintColor property for IQToolbar",@"Add the textField's placeholder text on IQToolbar",@"UIFont for IQToolbar placeholder text"],
@[@"Adjust textView's frame when it is too big in height"],
@[@"Override the keyboardAppearance for all UITextField/UITextView",@"All the UITextField keyboardAppearance is set using this property"],
@[@"Resigns Keyboard on touching outside of UITextField/View"],
@[@"plays inputClick sound on next/previous/done click"],
@[@"uses keyboard default animation curve style to move view"]];
keyboardManagerPropertyDetails = [NSArray arrayWithObjects:
[NSArray arrayWithObjects:@"Enable/Disable IQKeyboardManager",@"Set keyboard distance from textField",@"Prevent to show blank space between UIKeyboard and View",nil],
[NSArray arrayWithObjects:@"Automatic add the IQToolbar on UIKeyboard",@"AutoToolbar previous/next button managing behaviour",@"Uses textField's tintColor property for IQToolbar",@"Add the textField's placeholder text on IQToolbar",@"UIFont for IQToolbar placeholder text",nil],
[NSArray arrayWithObjects:@"Adjust textView's frame when it is too big in height",nil],
[NSArray arrayWithObjects:@"Override the keyboardAppearance for all UITextField/UITextView",@"All the UITextField keyboardAppearance is set using this property",nil],
[NSArray arrayWithObjects:@"Resigns Keyboard on touching outside of UITextField/View",nil],
[NSArray arrayWithObjects:@"plays inputClick sound on next/previous/done click",nil],
[NSArray arrayWithObjects:@"uses keyboard default animation curve style to move view",nil],nil];
}
- (IBAction)doneAction:(UIBarButtonItem *)sender
@@ -78,7 +79,7 @@
- (void)keyboardDistanceFromTextFieldAction:(UIStepper *)sender
{
[[IQKeyboardManager sharedManager] setKeyboardDistanceFromTextField:sender.value];
[self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:1 inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:1 inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
}
- (void)preventShowingBottomBlankSpaceAction:(UISwitch *)sender
@@ -99,7 +100,9 @@
- (void)shouldToolbarUsesTextFieldTintColorAction:(UISwitch *)sender
{
#ifdef NSFoundationVersionNumber_iOS_6_1
[[IQKeyboardManager sharedManager] setShouldToolbarUsesTextFieldTintColor:sender.on];
#endif
}
- (void)shouldShowTextFieldPlaceholder:(UISwitch *)sender
@@ -160,7 +163,7 @@
{
case 0:
{
return ([[IQKeyboardManager sharedManager] isEnabled] == NO) ? 1: [keyboardManagerProperties[section] count];
return ([[IQKeyboardManager sharedManager] isEnabled] == NO) ? 1: [[keyboardManagerProperties objectAtIndex:section] count];
}
break;
case 1:
@@ -175,20 +178,20 @@
}
else
{
return [keyboardManagerProperties[section] count];
return [[keyboardManagerProperties objectAtIndex:section] count];
}
}
break;
case 3:
{
return ([[IQKeyboardManager sharedManager] overrideKeyboardAppearance] == NO) ? 1: [keyboardManagerProperties[section] count];
return ([[IQKeyboardManager sharedManager] overrideKeyboardAppearance] == NO) ? 1: [[keyboardManagerProperties objectAtIndex:section] count];
}
break;
case 2:
case 4:
case 5:
case 6:
return [keyboardManagerProperties[section] count];
return [[keyboardManagerProperties objectAtIndex:section] count];
break;
default:
@@ -199,7 +202,7 @@
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return sectionTitles[section];
return [sectionTitles objectAtIndex:section];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
@@ -212,9 +215,9 @@
{
case 0:
{
SwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SwitchTableViewCell class]) forIndexPath:indexPath];
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row];
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row];
SwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SwitchTableViewCell class])];
cell.labelTitle.text = [[keyboardManagerProperties objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.labelSubtitle.text = [[keyboardManagerPropertyDetails objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.switchEnable.on = [[IQKeyboardManager sharedManager] isEnabled];
[cell.switchEnable removeTarget:nil action:NULL forControlEvents:UIControlEventAllEvents];
[cell.switchEnable addTarget:self action:@selector(enableAction:) forControlEvents:UIControlEventValueChanged];
@@ -223,9 +226,9 @@
break;
case 1:
{
StepperTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([StepperTableViewCell class]) forIndexPath:indexPath];
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row];
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row];
StepperTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([StepperTableViewCell class])];
cell.labelTitle.text = [[keyboardManagerProperties objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.labelSubtitle.text = [[keyboardManagerPropertyDetails objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.stepper.value = [[IQKeyboardManager sharedManager] keyboardDistanceFromTextField];
cell.labelStepperValue.text = [NSString stringWithFormat:@"%.0f",[[IQKeyboardManager sharedManager] keyboardDistanceFromTextField]];
[cell.stepper removeTarget:nil action:NULL forControlEvents:UIControlEventAllEvents];
@@ -235,9 +238,9 @@
break;
case 2:
{
SwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SwitchTableViewCell class]) forIndexPath:indexPath];
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row];
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row];
SwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SwitchTableViewCell class])];
cell.labelTitle.text = [[keyboardManagerProperties objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.labelSubtitle.text = [[keyboardManagerPropertyDetails objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.switchEnable.on = [[IQKeyboardManager sharedManager] preventShowingBottomBlankSpace];
[cell.switchEnable removeTarget:nil action:NULL forControlEvents:UIControlEventAllEvents];
[cell.switchEnable addTarget:self action:@selector(preventShowingBottomBlankSpaceAction:) forControlEvents:UIControlEventValueChanged];
@@ -253,9 +256,9 @@
{
case 0:
{
SwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SwitchTableViewCell class]) forIndexPath:indexPath];
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row];
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row];
SwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SwitchTableViewCell class])];
cell.labelTitle.text = [[keyboardManagerProperties objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.labelSubtitle.text = [[keyboardManagerPropertyDetails objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.switchEnable.on = [[IQKeyboardManager sharedManager] isEnableAutoToolbar];
[cell.switchEnable removeTarget:nil action:NULL forControlEvents:UIControlEventAllEvents];
[cell.switchEnable addTarget:self action:@selector(enableAutoToolbarAction:) forControlEvents:UIControlEventValueChanged];
@@ -264,18 +267,24 @@
break;
case 1:
{
NavigationTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([NavigationTableViewCell class]) forIndexPath:indexPath];
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row];
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row];
NavigationTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([NavigationTableViewCell class])];
cell.labelTitle.text = [[keyboardManagerProperties objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.labelSubtitle.text = [[keyboardManagerPropertyDetails objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
return cell;
}
break;
case 2:
{
SwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SwitchTableViewCell class]) forIndexPath:indexPath];
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row];
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row];
SwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SwitchTableViewCell class])];
cell.labelTitle.text = [[keyboardManagerProperties objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.labelSubtitle.text = [[keyboardManagerPropertyDetails objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
#ifdef NSFoundationVersionNumber_iOS_6_1
cell.switchEnable.on = [[IQKeyboardManager sharedManager] shouldToolbarUsesTextFieldTintColor];
#else
cell.switchEnable.on = NO;
cell.switchEnable.enabled = NO;
#endif
[cell.switchEnable removeTarget:nil action:NULL forControlEvents:UIControlEventAllEvents];
[cell.switchEnable addTarget:self action:@selector(shouldToolbarUsesTextFieldTintColorAction:) forControlEvents:UIControlEventValueChanged];
return cell;
@@ -283,9 +292,9 @@
break;
case 3:
{
SwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SwitchTableViewCell class]) forIndexPath:indexPath];
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row];
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row];
SwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SwitchTableViewCell class])];
cell.labelTitle.text = [[keyboardManagerProperties objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.labelSubtitle.text = [[keyboardManagerPropertyDetails objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.switchEnable.on = [[IQKeyboardManager sharedManager] shouldShowTextFieldPlaceholder];
[cell.switchEnable removeTarget:nil action:NULL forControlEvents:UIControlEventAllEvents];
[cell.switchEnable addTarget:self action:@selector(shouldShowTextFieldPlaceholder:) forControlEvents:UIControlEventValueChanged];
@@ -294,9 +303,9 @@
break;
case 4:
{
NavigationTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([NavigationTableViewCell class]) forIndexPath:indexPath];
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row];
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row];
NavigationTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([NavigationTableViewCell class])];
cell.labelTitle.text = [[keyboardManagerProperties objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.labelSubtitle.text = [[keyboardManagerPropertyDetails objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
return cell;
}
break;
@@ -309,9 +318,9 @@
{
case 0:
{
SwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SwitchTableViewCell class]) forIndexPath:indexPath];
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row];
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row];
SwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SwitchTableViewCell class])];
cell.labelTitle.text = [[keyboardManagerProperties objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.labelSubtitle.text = [[keyboardManagerPropertyDetails objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.switchEnable.on = [[IQKeyboardManager sharedManager] canAdjustTextView];
[cell.switchEnable removeTarget:nil action:NULL forControlEvents:UIControlEventAllEvents];
[cell.switchEnable addTarget:self action:@selector(canAdjustTextViewAction:) forControlEvents:UIControlEventValueChanged];
@@ -327,9 +336,9 @@
{
case 0:
{
SwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SwitchTableViewCell class]) forIndexPath:indexPath];
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row];
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row];
SwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SwitchTableViewCell class])];
cell.labelTitle.text = [[keyboardManagerProperties objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.labelSubtitle.text = [[keyboardManagerPropertyDetails objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.switchEnable.on = [[IQKeyboardManager sharedManager] overrideKeyboardAppearance];
[cell.switchEnable removeTarget:nil action:NULL forControlEvents:UIControlEventAllEvents];
[cell.switchEnable addTarget:self action:@selector(overrideKeyboardAppearanceAction:) forControlEvents:UIControlEventValueChanged];
@@ -338,9 +347,9 @@
break;
case 1:
{
NavigationTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([NavigationTableViewCell class]) forIndexPath:indexPath];
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row];
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row];
NavigationTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([NavigationTableViewCell class])];
cell.labelTitle.text = [[keyboardManagerProperties objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.labelSubtitle.text = [[keyboardManagerPropertyDetails objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
return cell;
}
break;
@@ -353,9 +362,9 @@
{
case 0:
{
SwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SwitchTableViewCell class]) forIndexPath:indexPath];
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row];
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row];
SwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SwitchTableViewCell class])];
cell.labelTitle.text = [[keyboardManagerProperties objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.labelSubtitle.text = [[keyboardManagerPropertyDetails objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.switchEnable.on = [[IQKeyboardManager sharedManager] shouldResignOnTouchOutside];
[cell.switchEnable removeTarget:nil action:NULL forControlEvents:UIControlEventAllEvents];
[cell.switchEnable addTarget:self action:@selector(shouldResignOnTouchOutsideAction:) forControlEvents:UIControlEventValueChanged];
@@ -371,9 +380,9 @@
{
case 0:
{
SwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SwitchTableViewCell class]) forIndexPath:indexPath];
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row];
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row];
SwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SwitchTableViewCell class])];
cell.labelTitle.text = [[keyboardManagerProperties objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.labelSubtitle.text = [[keyboardManagerPropertyDetails objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.switchEnable.on = [[IQKeyboardManager sharedManager] shouldPlayInputClicks];
[cell.switchEnable removeTarget:nil action:NULL forControlEvents:UIControlEventAllEvents];
[cell.switchEnable addTarget:self action:@selector(shouldPlayInputClicksAction:) forControlEvents:UIControlEventValueChanged];
@@ -389,9 +398,9 @@
{
case 0:
{
SwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SwitchTableViewCell class]) forIndexPath:indexPath];
cell.labelTitle.text = keyboardManagerProperties[indexPath.section][indexPath.row];
cell.labelSubtitle.text = keyboardManagerPropertyDetails[indexPath.section][indexPath.row];
SwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SwitchTableViewCell class])];
cell.labelTitle.text = [[keyboardManagerProperties objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.labelSubtitle.text = [[keyboardManagerPropertyDetails objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.switchEnable.on = [[IQKeyboardManager sharedManager] shouldAdoptDefaultKeyboardAnimation];
[cell.switchEnable removeTarget:nil action:NULL forControlEvents:UIControlEventAllEvents];
[cell.switchEnable addTarget:self action:@selector(shouldAdoptDefaultKeyboardAnimation:) forControlEvents:UIControlEventValueChanged];
@@ -425,16 +434,16 @@
if (selectedIndexPathForOptions.section == 1 && selectedIndexPathForOptions.row == 1)
{
controller.title = @"Toolbar Manage Behaviour";
controller.options = @[@"IQAutoToolbar By Subviews",@"IQAutoToolbar By Tag",@"IQAutoToolbar By Position"];
controller.options = [NSArray arrayWithObjects:@"IQAutoToolbar By Subviews",@"IQAutoToolbar By Tag",@"IQAutoToolbar By Position",nil];
controller.selectedIndex = [[IQKeyboardManager sharedManager] toolbarManageBehaviour];
}
else if (selectedIndexPathForOptions.section == 1 && selectedIndexPathForOptions.row == 4)
{
controller.title = @"Fonts";
controller.options = @[@"Bold System Font",@"Italic system font",@"Regular"];
controller.options = [NSArray arrayWithObjects:@"Bold System Font",@"Italic system font",@"Regular",nil];
NSArray *fonts = @[[UIFont boldSystemFontOfSize:12.0],[UIFont italicSystemFontOfSize:12],[UIFont systemFontOfSize:12]];
NSArray *fonts = [NSArray arrayWithObjects:[UIFont boldSystemFontOfSize:12.0],[UIFont italicSystemFontOfSize:12],[UIFont systemFontOfSize:12],nil];
UIFont *placeholderFont = [[IQKeyboardManager sharedManager] placeholderFont];
@@ -446,7 +455,7 @@
else if (selectedIndexPathForOptions.section == 3 && selectedIndexPathForOptions.row == 1)
{
controller.title = @"Keyboard Appearance";
controller.options = @[@"UIKeyboardAppearance Default",@"UIKeyboardAppearance Dark",@"UIKeyboardAppearance Light"];
controller.options = [NSArray arrayWithObjects:@"UIKeyboardAppearance Default",@"UIKeyboardAppearance Dark",@"UIKeyboardAppearance Light",nil];
controller.selectedIndex = [[IQKeyboardManager sharedManager] keyboardAppearance];
}
}
@@ -460,9 +469,9 @@
}
else if (selectedIndexPathForOptions.section == 1 && selectedIndexPathForOptions.row == 4)
{
NSArray *fonts = @[[UIFont boldSystemFontOfSize:12.0],[UIFont italicSystemFontOfSize:12],[UIFont systemFontOfSize:12]];
NSArray *fonts = [NSArray arrayWithObjects:[UIFont boldSystemFontOfSize:12.0],[UIFont italicSystemFontOfSize:12],[UIFont systemFontOfSize:12],nil];
[[IQKeyboardManager sharedManager] setPlaceholderFont:fonts[index]];
[[IQKeyboardManager sharedManager] setPlaceholderFont:[fonts objectAtIndex:index]];
}
else if (selectedIndexPathForOptions.section == 3 && selectedIndexPathForOptions.row == 1)
{

View File

@@ -7,6 +7,8 @@
@interface SpecialCaseViewController ()<UISearchBarDelegate,UITextFieldDelegate,UITextViewDelegate,UIGestureRecognizerDelegate>
-(void)updateUI;
@end
@implementation SpecialCaseViewController

View File

@@ -10,6 +10,8 @@
@implementation StepperTableViewCell
@synthesize labelTitle, labelSubtitle, stepper, labelStepperValue;
- (void)awakeFromNib
{
[super awakeFromNib];

View File

@@ -9,6 +9,7 @@
#import "SwitchTableViewCell.h"
@implementation SwitchTableViewCell
@synthesize labelTitle, labelSubtitle, switchEnable;
- (void)awakeFromNib
{

View File

@@ -38,7 +38,7 @@
}
UITextField *textField = (UITextField *)[cell.contentView viewWithTag:123];
textField.placeholder = [NSString stringWithFormat:@"Cell %@", @(indexPath.row)];
textField.placeholder = [NSString stringWithFormat:@"Cell %@",[NSNumber numberWithInteger:indexPath.row]];
return cell;
}

View File

@@ -8,6 +8,12 @@
#import "IQDropDownTextField.h"
#import "IQUIView+IQKeyboardToolbar.h"
@interface TextFieldViewController ()
-(void)refreshUI;
@end
@implementation TextFieldViewController
{
IQKeyboardReturnKeyHandler *returnKeyHandler;
@@ -57,7 +63,7 @@
[returnKeyHandler setLastTextFieldReturnKeyType:UIReturnKeyDone];
returnKeyHandler.toolbarManageBehaviour = IQAutoToolbarByPosition;
[dropDownTextField setItemList:@[@"Zero Line Of Code",
[dropDownTextField setItemList:[NSArray arrayWithObjects:@"Zero Line Of Code",
@"No More UIScrollView",
@"No More Subclasses",
@"No More Manual Work",
@@ -73,9 +79,7 @@
@"Auto adjust textView's height ",
@"Adopt tintColor from textField",
@"Customize keyboardAppearance",
@"play sound on next/prev/done",
]];
@"play sound on next/prev/done",nil]];
}
-(void)viewWillAppear:(BOOL)animated
@@ -116,7 +120,10 @@
TextFieldViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([TextFieldViewController class])];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
navigationController.navigationBar.tintColor = self.navigationController.navigationBar.tintColor;
#ifdef NSFoundationVersionNumber_iOS_6_1
navigationController.navigationBar.barTintColor = self.navigationController.navigationBar.barTintColor;
#endif
navigationController.navigationBar.titleTextAttributes = self.navigationController.navigationBar.titleTextAttributes;
[navigationController setModalTransitionStyle:arc4random()%4];

View File

@@ -12,14 +12,17 @@
@implementation TextSelectionViewController
@synthesize data = _data;
@synthesize tableView = _tableView;
- (void)viewDidLoad
{
[super viewDidLoad];
self.tableView.delegate = self;
self.tableView.dataSource = self;
_data = @[@"Hello", @"This is a demo code", @"Issue #56", @"With mutiple cells", @"And some useless text.",
_data = [NSArray arrayWithObjects:@"Hello", @"This is a demo code", @"Issue #56", @"With mutiple cells", @"And some useless text.",
@"Hello", @"This is a demo code", @"Issue #56", @"With mutiple cells", @"And some useless text.",
@"Hello", @"This is a demo code", @"Issue #56", @"With mutiple cells", @"And some useless text."];
@"Hello", @"This is a demo code", @"Issue #56", @"With mutiple cells", @"And some useless text.",nil];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
@@ -47,7 +50,7 @@
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(5,7,135,30)];
textView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
textView.backgroundColor = [UIColor clearColor];
textView.text = _data[indexPath.row];
textView.text = [_data objectAtIndex:indexPath.row];
textView.dataDetectorTypes = UIDataDetectorTypeAll;
textView.scrollEnabled = NO;
textView.editable = NO;

View File

@@ -5,6 +5,12 @@
#import "TextViewSpecialCaseViewController.h"
#import "IQKeyboardManager.h"
@interface TextViewSpecialCaseViewController ()
-(void)refreshUI;
@end
@implementation TextViewSpecialCaseViewController
-(IBAction)canAdjustTextView:(UIBarButtonItem*)barButton

View File

@@ -14,6 +14,9 @@
- (IBAction)shareClicked:(UIBarButtonItem *)sender
{
#ifdef NSFoundationVersionNumber_iOS_5_1
NSString *shareString = @"IQKeyboardManager is really great control for iOS developer to manage keyboard-textField.";
UIImage *shareImage = [UIImage imageNamed:@"IQKeyboardManagerScreenshot"];
NSURL *youtubeUrl = [NSURL URLWithString:@"http://youtu.be/6nhLw6hju2A"];
@@ -29,6 +32,7 @@
UIActivityTypeSaveToCameraRoll];
controller.excludedActivityTypes = excludedActivities;
[self presentViewController:controller animated:YES completion:nil];
#endif
}
-(void)viewDidLoad
@@ -54,11 +58,15 @@
return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
}
#ifdef NSFoundationVersionNumber_iOS_5_1
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
#endif
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;

View File

@@ -42,7 +42,7 @@ alt="IQKeyboardManager Demo Video" width="480" height="360" border="10" /></a>
Minimum iOS Target: iOS 5.0
Minimum Xcode Version: Xcode 5.0
Minimum Xcode Version: Xcode 4.2
#### Demo Project:-