@@ -15,30 +15,23 @@ A small (but cool) tool for handling UIKeyboard appearing and disappearing in yo
15
15
## 📦 Installation
16
16
17
17
### Carthage
18
+ ~~~ bash
19
+ github " nodes-ios/KeyboardHelper" ~ > 1.0
18
20
~~~
19
- github "nodes-ios/KeyboardHelper"
20
- ~~~
21
+
22
+ > Last versions compatible with lower Swift versions:
23
+ >
24
+ > ** Swift 2.3**
25
+ > ` github "nodes-ios/KeyboardHelper" == 0.10.0 `
26
+ >
27
+ > ** Swift 2.2**
28
+ > ` github "nodes-ios/KeyboardHelper" == 0.9.4 `
21
29
22
30
### CocoaPods
23
31
~~~
24
- pod 'KeyboardHelper', '~> 0.9 '
32
+ pod 'KeyboardHelper', '~> 1.0 '
25
33
~~~
26
34
27
- ### Swit Package Manager
28
- To use KeyboardHelper as a [ Swift Package Manager] ( https://swift.org/package-manager/ ) package just add the following to your ` Package.swift ` file.
29
-
30
- ~~~ swift
31
- import PackageDescription
32
-
33
- let package = Package (
34
- name : " YourPackage" ,
35
- dependencies : [
36
- .Package (url : " https://github.com/nodes-ios/KeyboardHelper.git" , majorVersion : 0 )
37
- ]
38
- )
39
- ~~~
40
-
41
- ** NOTE:** This doesn't currently work as SPM doesn't support iOS, but once it will we will already be supporting it! :)
42
35
43
36
## 🔧 Setup
44
37
Implement ` KeyboardNotificationDelegate ` in your UIViewController.
@@ -47,12 +40,16 @@ Implement `KeyboardNotificationDelegate` in your UIViewController.
47
40
class ViewController : UIViewController , KeyboardNotificationDelegate
48
41
```
49
42
50
- Add a `KeyboardHelper` private variable and initialize it, setting the delegate.
43
+ Add a `KeyboardHelper` private variable, initialize it and set the delegate.
51
44
52
45
```swift
53
46
private var keyboardHelper : KeyboardHelper ?
54
- ...
55
- self.keyboardHelper = KeyboardHelper(delegate: self )
47
+
48
+ func viewDidLoad() {
49
+ ...
50
+ self .keyboardHelper = KeyboardHelper (delegate : self )
51
+ ...
52
+ }
56
53
```
57
54
Implement the two methods in the ` KeyboardNotificationDelegate ` :
58
55
@@ -78,17 +75,17 @@ func keyboardWillAppear(_ info: KeyboardAppearanceInfo) {
78
75
completion :nil )
79
76
}
80
77
81
- func keyboardWillDisappear (_ info : KeyboardAppearanceInfo) {
82
- UIView.animate (withDuration : TimeInterval (info.animationDuration ),
83
- delay : 0 ,
84
- options : info.animationOptions ,
85
- animations : {
86
- let insets = UIEdgeInsetsZero
87
- self .scrollView .contentInset = insets
88
- self .scrollView .scrollIndicatorInsets = insets
89
- },
90
- completion :nil )
91
- }
78
+ func keyboardWillDisappear (_ info : KeyboardAppearanceInfo) {
79
+ UIView.animate (withDuration : TimeInterval (info.animationDuration ),
80
+ delay : 0 ,
81
+ options : info.animationOptions ,
82
+ animations : {
83
+ let insets = UIEdgeInsetsZero
84
+ self .scrollView .contentInset = insets
85
+ self .scrollView .scrollIndicatorInsets = insets
86
+ },
87
+ completion :nil )
88
+ }
92
89
```
93
90
94
91
The ` KeyboardAppearanceInfo ` object has the following properties:
0 commit comments