forked from agilehands/iOS-KeyboardHelper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
69 lines (47 loc) · 1.96 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
KeyboarHelper adds a inputAccessoryView with Previsou, Next and Done button.
If any textfield or textarea is selected a toolbar with the above buttons
will be shown just above the keyboard.
Previous button is absent if the first textfield/view is selected and Next button is absent
if the last textfield/view is selected.
A callback to the done button can be assigned as selector or block.
KeyboardHelper works with a ViewController object.
Example:
Step 0: Add the files:
Add the KeyboardHelper folder into your project. It has just two files:
1. KeyboardHelper.h
2. KehboardHelper.m
Step 1: Declare a property
...
#import "KeyboardHelper.h"
...
...
@property (nonatomic, strong) KeyboardHelper* kbHelper;
Step 2: Initialize in viewDidLoad method
// in viewDidLoad method:
// using selector
self.kbHelper = [[KeyboardHelper alloc] initWithViewController:self onDoneSelector:@selector(onDone)];
// using block
self.kbHelper = [[KeyboardHelper alloc] initWithViewController:self onDoneAction:^(void){
NSLog(@"On Done!!");
}];
NOTE: If view is not loaded, there will be an exception
Step 3: Enable/Disable
Since KeyboardHelper observs UIKeyboardWillShowNotification and UIKeyboardWillHideNotification,
it needs to be remove itself from observing before the view disappears.
- (void) viewWillAppear:(BOOL)animated{
[self.kbHelper enable];
}
- (void) viewWillDisappear:(BOOL)animated{
[self.kbHelper disable];
}
Step 4: Delegates
KeyboardHelper sets itself as delegate to all the UITextField and UITextView present
in the viewcontroller it initialized with.
So, it exposes these two properities allowing any external delegate:
1. textViewDelegate
2. textFieldDelegate
Known Issues:
1. Doesn't work well in Landscape mode.
2. Landscape right orientation is not supported.
THANKS FOR ANY FEEDBACK AND BUG REPORT :)
Blog Link: http://amanpages.com/wordpress/iphone-app-development-core-sdk-cocoa/keyboard-helper-for-iphone-apps-using-inputaccessoryview-with-previous-next-and-done-buttons/