Skip to content

Commit e005778

Browse files
committed
Updated README.md for #147
1 parent 2850703 commit e005778

File tree

6 files changed

+94
-47
lines changed

6 files changed

+94
-47
lines changed

IQKeyBoardManager/IQKeyboardManager.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ extern NSInteger const kIQPreviousNextButtonToolbarTag;
6666
/*!
6767
@property enable
6868
69-
@abstract enable/disable the keyboard manager. Default is YES(Enabled when class loads in `+(void)load` method).
69+
@abstract enable/disable managing distance between keyboard and textField. Default is YES(Enabled when class loads in `+(void)load` method).
7070
*/
7171
@property(nonatomic, assign, getter = isEnabled) BOOL enable;
7272

@@ -138,6 +138,13 @@ extern NSInteger const kIQPreviousNextButtonToolbarTag;
138138
*/
139139
@property(nonatomic, assign) BOOL canAdjustTextView;
140140

141+
/*!
142+
@property shouldFixTextViewClip
143+
144+
@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.
145+
*/
146+
@property(nonatomic, assign) BOOL shouldFixTextViewClip;
147+
141148

142149
/*******************************************/
143150

IQKeyBoardManager/IQKeyboardManager.m

+18-15
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ -(instancetype)init
217217
[self setKeyboardAppearance:UIKeyboardAppearanceDefault];
218218

219219
[self setEnableAutoToolbar:YES];
220+
[self setShouldFixTextViewClip:YES];
220221
[self setPreventShowingBottomBlankSpace:YES];
221222
[self setShouldShowTextFieldPlaceholder:YES];
222223
[self setShouldAdoptDefaultKeyboardAnimation:YES];
@@ -1025,23 +1026,25 @@ -(void)textFieldViewDidEndEditing:(NSNotification*)notification
10251026
/* UITextViewTextDidChangeNotificationBug, fix for iOS 7.0.x - http://stackoverflow.com/questions/18966675/uitextview-in-ios7-clips-the-last-line-of-text-string */
10261027
-(void)textFieldViewDidChange:(NSNotification*)notification // (Bug ID: #18)
10271028
{
1028-
UITextView *textView = (UITextView *)notification.object;
1029-
1030-
CGRect line = [textView caretRectForPosition: textView.selectedTextRange.start];
1031-
CGFloat overflow = CGRectGetMaxY(line) - (textView.contentOffset.y + CGRectGetHeight(textView.bounds) - textView.contentInset.bottom - textView.contentInset.top);
1032-
1033-
//Added overflow conditions (Bug ID: 95)
1034-
if ( overflow > 0 && overflow < FLT_MAX)
1029+
if (_shouldFixTextViewClip == YES)
10351030
{
1036-
// We are at the bottom of the visible text and introduced a line feed, scroll down (iOS 7 does not do it)
1037-
// Scroll caret to visible area
1038-
CGPoint offset = textView.contentOffset;
1039-
offset.y += overflow + 7; // leave 7 pixels margin
1031+
UITextView *textView = (UITextView *)notification.object;
1032+
CGRect line = [textView caretRectForPosition: textView.selectedTextRange.start];
1033+
CGFloat overflow = CGRectGetMaxY(line) - (textView.contentOffset.y + CGRectGetHeight(textView.bounds) - textView.contentInset.bottom - textView.contentInset.top);
10401034

1041-
// Cannot animate with setContentOffset:animated: or caret will not appear
1042-
[UIView animateWithDuration:_animationDuration delay:0 options:(_animationCurve|UIViewAnimationOptionBeginFromCurrentState) animations:^{
1043-
[textView setContentOffset:offset];
1044-
} completion:NULL];
1035+
//Added overflow conditions (Bug ID: 95)
1036+
if ( overflow > 0 && overflow < FLT_MAX)
1037+
{
1038+
// We are at the bottom of the visible text and introduced a line feed, scroll down (iOS 7 does not do it)
1039+
// Scroll caret to visible area
1040+
CGPoint offset = textView.contentOffset;
1041+
offset.y += overflow + 7; // leave 7 pixels margin
1042+
1043+
// Cannot animate with setContentOffset:animated: or caret will not appear
1044+
[UIView animateWithDuration:_animationDuration delay:0 options:(_animationCurve|UIViewAnimationOptionBeginFromCurrentState) animations:^{
1045+
[textView setContentOffset:offset];
1046+
} completion:NULL];
1047+
}
10451048
}
10461049
}
10471050

KeyboardTextFieldDemo/.DS_Store

0 Bytes
Binary file not shown.

KeyboardTextFieldDemo/IQKeyboardManager.xcodeproj/xcuserdata/iftekhar.xcuserdatad/xcschemes/IQKeyboard.xcscheme

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<BuildableReference
1616
BuildableIdentifier = "primary"
1717
BlueprintIdentifier = "C0B63B9A1781FAB1008D3B64"
18-
BuildableName = "IQKeyboard.app"
18+
BuildableName = "IQKeyboardManager.app"
1919
BlueprintName = "IQKeyboardManager"
2020
ReferencedContainer = "container:IQKeyboardManager.xcodeproj">
2121
</BuildableReference>
@@ -33,7 +33,7 @@
3333
<BuildableReference
3434
BuildableIdentifier = "primary"
3535
BlueprintIdentifier = "C0B63B9A1781FAB1008D3B64"
36-
BuildableName = "IQKeyboard.app"
36+
BuildableName = "IQKeyboardManager.app"
3737
BlueprintName = "IQKeyboardManager"
3838
ReferencedContainer = "container:IQKeyboardManager.xcodeproj">
3939
</BuildableReference>
@@ -52,7 +52,7 @@
5252
<BuildableReference
5353
BuildableIdentifier = "primary"
5454
BlueprintIdentifier = "C0B63B9A1781FAB1008D3B64"
55-
BuildableName = "IQKeyboard.app"
55+
BuildableName = "IQKeyboardManager.app"
5656
BlueprintName = "IQKeyboardManager"
5757
ReferencedContainer = "container:IQKeyboardManager.xcodeproj">
5858
</BuildableReference>
@@ -70,7 +70,7 @@
7070
<BuildableReference
7171
BuildableIdentifier = "primary"
7272
BlueprintIdentifier = "C0B63B9A1781FAB1008D3B64"
73-
BuildableName = "IQKeyboard.app"
73+
BuildableName = "IQKeyboardManager.app"
7474
BlueprintName = "IQKeyboardManager"
7575
ReferencedContainer = "container:IQKeyboardManager.xcodeproj">
7676
</BuildableReference>

README.md

+64-27
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Often while developing an app, We ran into an issues where the iPhone `UIKeyboar
77

88
####Key Features
99

10-
1) `CODELESS, Zero Line Of Code`
10+
1) **CODELESS**, Zero Line Of Code`
1111

1212
2) `Works Automatically`
1313

@@ -75,20 +75,27 @@ If you need to port your project to another location you may need to adjust `Fra
7575

7676
#### Source Code Method:-
7777

78-
Just drag and drop `IQKeyBoardManager` directory from demo project to your project. That's it. No need to write any single line of code. It will enable automatically.
78+
Just ***drag and drop*** `IQKeyBoardManager` directory from demo project to your project. That's it.
7979

8080
## Known Issues:-
8181

8282
![Known Issue 1](./KeyboardTextFieldDemo/Screenshot/IQKeyboardManagerKnownIssue1.png)
8383

84-
1) **Keyboard does not appear in iOS Simulator** ([#62](https://github.com/hackiftekhar/IQKeyboardManager/issues/62), [#72](https://github.com/hackiftekhar/IQKeyboardManager/issues/72), [#75](https://github.com/hackiftekhar/IQKeyboardManager/issues/75), [#90](https://github.com/hackiftekhar/IQKeyboardManager/issues/90), [#100](https://github.com/hackiftekhar/IQKeyboardManager/issues/100))
84+
**1) Keyboard does not appear in iOS Simulator** ([#62](https://github.com/hackiftekhar/IQKeyboardManager/issues/62), [#72](https://github.com/hackiftekhar/IQKeyboardManager/issues/72), [#75](https://github.com/hackiftekhar/IQKeyboardManager/issues/75), [#90](https://github.com/hackiftekhar/IQKeyboardManager/issues/90), [#100](https://github.com/hackiftekhar/IQKeyboardManager/issues/100))
8585

8686
If keyboard does not appear in iOS Simulator and only toolbar is appearing over it (if enableAutoToolbar = YES), then check this setting
8787

88-
**Xcode 6:-** Goto ***iOS Simulator->Menu->Hardware->Keyboard->Connect Hardware Keyboard***, and deselect that.
88+
***Xcode 6:-*** Goto ***iOS Simulator->Menu->Hardware->Keyboard->Connect Hardware Keyboard***, and deselect that.
8989

90-
**Xcode 5 and earlier:-** Goto ***iOS Simulator->Menu->Hardware->Simulate Hardware Keyboard***, and deselect that.
90+
***Xcode 5 and earlier:-*** Goto ***iOS Simulator->Menu->Hardware->Simulate Hardware Keyboard***, and deselect that.
9191

92+
**2) setEnable = NO doesn't disable automatic UIToolbar** ([#117](https://github.com/hackiftekhar/IQKeyboardManager/issues/117), [#136](https://github.com/hackiftekhar/IQKeyboardManager/issues/136), [#147](https://github.com/hackiftekhar/IQKeyboardManager/issues/147))
93+
94+
If you set ***[[IQKeyboardManager sharedManager] setEnable:NO]*** and still automatic toolbar appears on textFields? Probably you haven't heard about ***@property enableAutoToolbar***.
95+
96+
***@property enable :*** It enable/disable managing distance between keyboard and textField, and doesn't affect autoToolbar feature.
97+
98+
***@property enableAutoToolbar :*** It enable/disable automatic creation of toolbar, please set enableAutoToolbar to NO if you don't want to add automatic toolbar.
9299

93100
Manual Management:-
94101
---
@@ -135,7 +142,7 @@ Manual Management:-
135142

136143

137144
#### Keyboard Return Key Handling:-
138-
If you would like to implement keyboard `Return Key` as `Next` button, then you can use `IQKeyboardReturnKeyHandler`.([#38](https://github.com/hackiftekhar/IQKeyboardManager/issues/38), [#63](https://github.com/hackiftekhar/IQKeyboardManager/issues/63))
145+
If you would like to implement keyboard **Return Key** as **Next/Done** button, then you can use **IQKeyboardReturnKeyHandler**.([#38](https://github.com/hackiftekhar/IQKeyboardManager/issues/38), [#63](https://github.com/hackiftekhar/IQKeyboardManager/issues/63))
139146

140147
1) Create an instance variable of `IQKeyboardReturnKeyHandler` and instantiate it in `viewDidLoad` with ViewController object like this:-
141148

@@ -215,14 +222,14 @@ textField.inputAccessoryView = [[UIView alloc] init];
215222

216223
#### Doing custom work on textField with returning NO in `textFieldShouldBeginEditing:` delegate:-
217224

218-
Generally if developer need to perform some custom task on a particular textField click, then usually developer write their custom code inside `textFieldShouldBeginEditing:` and returning NO for that textField. But if you are using IQKeyboardManager, then IQKeyboardManager also asks textField to recognize it can become first responder or not using `canBecomeFirstResponder` in `IQUIView+Hierarchy` category, and textField asks it's delegate to respond from `textFieldShouldBeginEditing:`, so this method is called for each textField everytime when a textField becomeFirstResponder. Unintentionally custom code runs multiple times even when we do not touch the textField to become it as first responder. To overcome this situation please use `isAskingCanBecomeFirstResponder` BOOL property to check that the delegate is called by IQKeyboardManager or not. ([#88](https://github.com/hackiftekhar/IQKeyboardManager/issues/88))
225+
Generally if developer need to perform some custom task on a particular textField click, then usually developer write their custom code inside ***textFieldShouldBeginEditing:*** and returning NO for that textField. But if you are using IQKeyboardManager, then IQKeyboardManager also asks textField to recognize it can become first responder or not using ***canBecomeFirstResponder*** in `IQUIView+Hierarchy` category, and textField asks it's delegate to respond from `textFieldShouldBeginEditing:`, so this method is called for each textField everytime when a textField becomeFirstResponder. Unintentionally custom code runs multiple times even when we do not touch the textField to become it as first responder. To overcome this situation please use ***isAskingCanBecomeFirstResponder*** BOOL property to check that the delegate is called by IQKeyboardManager or not. ([#88](https://github.com/hackiftekhar/IQKeyboardManager/issues/88))
219226

220227
1) You may need to import `IQUIView+Hierarchy` category
221228
```
222229
#import "IQUIView+Hierarchy.h"
223230
```
224231

225-
2) check for `isAskingCanBecomeFirstResponder` in `textFieldShouldBeginEditing:` delegate.
232+
2) check for ***isAskingCanBecomeFirstResponder*** in `textFieldShouldBeginEditing:` delegate.
226233

227234
```
228235
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
@@ -245,55 +252,85 @@ Generally if developer need to perform some custom task on a particular textFiel
245252
[![IQKeyboardManager CFD](./KeyboardTextFieldDemo/Screenshot/IQKeyboardManagerCFD.jpg)](https://raw.githubusercontent.com/hackiftekhar/IQKeyboardManager/master/KeyboardTextFieldDemo/Screenshot/IQKeyboardManagerCFD.jpg)
246253

247254

248-
Properties and functions usage:-
255+
##Properties and functions usage:-
256+
257+
258+
**UIKeyboard handling**
249259
---
250-
1) `+sharedManager`
260+
261+
**1) +(instancetype)sharedManager :**
251262
Returns the default singleton instance.
252263

253-
2) `enable`
264+
**2) @property BOOL enable :**
254265
Use this to enable/disable managing distance between keyboard & textField/textView).
255266

256-
3) `keyboardDistanceFromTextField`
267+
**3) @property CGFloat keyboardDistanceFromTextField :**
257268
Set Distance between keyboard & textField. Can't be less than zero. Default is 10.
258269

259-
4) `enableAutoToolbar`
270+
**4) @property BOOL preventShowingBottomBlankSpace :**
271+
Prevent to show bottom blanck area when keyboard slide up the view. ([#93](https://github.com/hackiftekhar/IQKeyboardManager/issues/93)). Default is YES.
272+
273+
**IQToolbar handling**
274+
---
275+
276+
**5) @property BOOL enableAutoToolbar :**
260277
Enable autoToolbar behaviour. If It is set to NO. You have to manually create UIToolbar for keyboard. Default is YES.
261278

262-
5) `toolbarManageBehaviour`
279+
**6) @property IQAutoToolbarManageBehaviour toolbarManageBehaviour :**
263280
Setting toolbar behaviour to IQAutoToolbarBySubviews to manage previous/next according to UITextField's hierarchy in it's SuperView. Set it to IQAutoToolbarByTag to manage previous/next according to UITextField's tag property in increasing order. Default is IQAutoToolbarBySubviews.
264281

265-
6) `shouldToolbarUsesTextFieldTintColor`
282+
**7) @property BOOL shouldToolbarUsesTextFieldTintColor :**
266283
If YES, then uses textField's tintColor property for IQToolbar, otherwise tintColor is black. Default is NO. ([#27](https://github.com/hackiftekhar/IQKeyboardManager/issues/27))
267284

268-
7) `shouldShowTextFieldPlaceholder`
285+
**8) @property BOOL shouldShowTextFieldPlaceholder :**
269286
If YES, then it add the textField's placeholder text on IQToolbar. Default is YES. ([#27](https://github.com/hackiftekhar/IQKeyboardManager/issues/27))
270287

271-
8) `placeholderFont`
288+
**9) @property UIFont \*placeholderFont :**
272289
placeholder Font. Default is nil. ([#27](https://github.com/hackiftekhar/IQKeyboardManager/issues/27))
273290

274-
9) `canAdjustTextView`
291+
292+
**UITextView handling**
293+
---
294+
295+
**10) @property BOOL canAdjustTextView :**
275296
Giving permission to modify TextView's frame. Adjust textView's frame when it is too big in height. Default is NO. ([#30](https://github.com/hackiftekhar/IQKeyboardManager/issues/30))
276297

277-
10) `overrideKeyboardAppearance`
298+
**11) @property BOOL shouldFixTextViewClip :**
299+
Adjust textView's contentInset to fix fix for iOS 7.0.x -([#Stackoverflow](http://stackoverflow.com/questions/18966675/uitextview-in-ios7-clips-the-last-line-of-text-string)). Default is YES.
300+
301+
302+
**UIKeyboard Appearance overriding**
303+
---
304+
305+
**12) @property BOOL overrideKeyboardAppearance :**
278306
Override the keyboardAppearance for all textField/textView. Default is NO.
279307

280-
11) `keyboardAppearance`
308+
**13) @property UIKeyboardAppearance keyboardAppearance :**
281309
If overrideKeyboardAppearance is YES, then all the textField keyboardAppearance is set using this property.
282310

283-
12) `shouldResignOnTouchOutside`
311+
312+
**UITextField/UITextView Resign handling**
313+
---
314+
315+
**14) @property BOOL shouldResignOnTouchOutside :**
284316
Resign textField if touched outside of UITextField/UITextView. ([#14](https://github.com/hackiftekhar/IQKeyboardManager/issues/14))
285317

286-
13) `-resignFirstResponder`
318+
**15) -(void)resignFirstResponder :**
287319
Resigns currently first responder field.
288320

289-
14) `shouldPlayInputClicks`
321+
322+
**UISound handling**
323+
---
324+
325+
**16) @property BOOL shouldPlayInputClicks :**
290326
If YES, then it plays inputClick sound on next/previous/done click. Default is NO.
291327

292-
15) `shouldAdoptDefaultKeyboardAnimation`
293-
If YES, then uses keyboard default animation curve style to move view, otherwise uses UIViewAnimationOptionCurveEaseOut animation style. Default is YES.
294328

295-
16) `preventShowingBottomBlankSpace`
296-
Prevent to show bottom black area when keyboard slide up the view. ([#93](https://github.com/hackiftekhar/IQKeyboardManager/issues/93))
329+
**UIAnimation handling**
330+
---
331+
332+
**17) @property BOOL shouldAdoptDefaultKeyboardAnimation :**
333+
If YES, then uses keyboard default animation curve style to move view, otherwise uses UIViewAnimationOptionCurveEaseOut animation style. Default is YES.
297334

298335

299336

0 commit comments

Comments
 (0)