Skip to content
This repository was archived by the owner on Mar 10, 2022. It is now read-only.

Commit e10aefb

Browse files
mariuscDominik Hadl
authored andcommitted
Updated README and example project
1 parent ba56948 commit e10aefb

File tree

6 files changed

+24
-21
lines changed

6 files changed

+24
-21
lines changed

Example/Cartfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github "nodes-ios/KeyboardHelper" "master"
1+
github "nodes-ios/KeyboardHelper" "swift-3.0"

Example/Cartfile.resolved

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github "nodes-ios/KeyboardHelper" "30ed3728bf10b7d2a606d1e23bb23c12eea02222"
1+
github "nodes-ios/KeyboardHelper" "58d7c2bf19f7bc93d733290f06ae0eedf03f18a5"

Example/KeyboardHelperDemo.xcodeproj/project.pbxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
TargetAttributes = {
129129
29F30E661C807E2A00C77AF4 = {
130130
CreatedOnToolsVersion = 7.2;
131+
LastSwiftMigration = 0810;
131132
};
132133
};
133134
};
@@ -289,6 +290,7 @@
289290
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
290291
PRODUCT_BUNDLE_IDENTIFIER = dk.nodes.KeyboardHelperDemo;
291292
PRODUCT_NAME = "$(TARGET_NAME)";
293+
SWIFT_VERSION = 3.0;
292294
};
293295
name = Debug;
294296
};
@@ -305,6 +307,7 @@
305307
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
306308
PRODUCT_BUNDLE_IDENTIFIER = dk.nodes.KeyboardHelperDemo;
307309
PRODUCT_NAME = "$(TARGET_NAME)";
310+
SWIFT_VERSION = 3.0;
308311
};
309312
name = Release;
310313
};

Example/KeyboardHelperDemo/AppDelegate.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414
var window: UIWindow?
1515

1616

17-
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
1818
// Override point for customization after application launch.
1919
return true
2020
}
2121

22-
func applicationWillResignActive(application: UIApplication) {
22+
func applicationWillResignActive(_ application: UIApplication) {
2323
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
2424
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
2525
}
2626

27-
func applicationDidEnterBackground(application: UIApplication) {
27+
func applicationDidEnterBackground(_ application: UIApplication) {
2828
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
2929
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
3030
}
3131

32-
func applicationWillEnterForeground(application: UIApplication) {
32+
func applicationWillEnterForeground(_ application: UIApplication) {
3333
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
3434
}
3535

36-
func applicationDidBecomeActive(application: UIApplication) {
36+
func applicationDidBecomeActive(_ application: UIApplication) {
3737
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
3838
}
3939

40-
func applicationWillTerminate(application: UIApplication) {
40+
func applicationWillTerminate(_ application: UIApplication) {
4141
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
4242
}
4343

Example/KeyboardHelperDemo/ViewController.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import KeyboardHelper
1111

1212
class ViewController: UIViewController, KeyboardNotificationDelegate {
1313

14-
private var tapGesture: UITapGestureRecognizer!
15-
private var keyboardHelper : KeyboardHelper?
14+
fileprivate var tapGesture: UITapGestureRecognizer!
15+
fileprivate var keyboardHelper : KeyboardHelper?
1616
@IBOutlet weak var scrollView: UIScrollView!
1717

1818
override func viewDidLoad() {
@@ -21,7 +21,7 @@ class ViewController: UIViewController, KeyboardNotificationDelegate {
2121

2222
self.tapGesture = UITapGestureRecognizer(target: self, action: #selector(ViewController.dismissKeyboard))
2323
self.view.addGestureRecognizer(tapGesture)
24-
self.tapGesture.enabled = true
24+
self.tapGesture.isEnabled = true
2525

2626
self.keyboardHelper = KeyboardHelper(delegate: self)
2727
}
@@ -30,20 +30,20 @@ class ViewController: UIViewController, KeyboardNotificationDelegate {
3030
self.view.endEditing(true)
3131
}
3232

33-
func keyboardWillAppear(info: KeyboardAppearanceInfo) {
33+
func keyboardWillAppear(_ info: KeyboardAppearanceInfo) {
3434
info.animateAlong({ () -> Void in
3535
let insets = UIEdgeInsetsMake(0, 0, info.endFrame.size.height, 0)
3636
self.scrollView.contentInset = insets
3737
self.scrollView.scrollIndicatorInsets = insets
3838
}) { finished in }
3939
}
4040

41-
func keyboardWillDisappear(info: KeyboardAppearanceInfo) {
42-
UIView.animateWithDuration(NSTimeInterval(info.animationDuration),
41+
func keyboardWillDisappear(_ info: KeyboardAppearanceInfo) {
42+
UIView.animate(withDuration: TimeInterval(info.animationDuration),
4343
delay: 0,
4444
options: info.animationOptions,
4545
animations: {
46-
let insets = UIEdgeInsetsZero
46+
let insets = UIEdgeInsets.zero
4747
self.scrollView.contentInset = insets
4848
self.scrollView.scrollIndicatorInsets = insets
4949
},

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,17 @@ self.keyboardHelper = KeyboardHelper(delegate: self)
5757
Implement the two methods in the `KeyboardNotificationDelegate`:
5858

5959
```swift
60-
public func keyboardWillAppear(info: KeyboardHelper.KeyboardAppearanceInfo)
61-
public func keyboardWillDisappear(info: KeyboardHelper.KeyboardAppearanceInfo)
60+
public func keyboardWillAppear(_ info: KeyboardHelper.KeyboardAppearanceInfo)
61+
public func keyboardWillDisappear(_ info: KeyboardHelper.KeyboardAppearanceInfo)
6262
```
6363

6464
Both methods take as argument a `KeyboardAppearanceInfo` object, which is basically a wrapper over the `userInfo` dictionary of the `UIKeyboardWillShowNotification` and `UIKeyboardWillHideNotification` notifications.
6565

6666
One example of implementation for the two delegate methods is:
6767

6868
```swift
69-
func keyboardWillAppear(info: KeyboardAppearanceInfo) {
70-
UIView.animateWithDuration(NSTimeInterval(info.animationDuration),
69+
func keyboardWillAppear(_ info: KeyboardAppearanceInfo) {
70+
UIView.animate(withDuration: TimeInterval(info.animationDuration),
7171
delay: 0,
7272
options: info.animationOptions,
7373
animations: {
@@ -78,8 +78,8 @@ func keyboardWillAppear(info: KeyboardAppearanceInfo) {
7878
completion:nil)
7979
}
8080

81-
func keyboardWillDisappear(info: KeyboardAppearanceInfo) {
82-
UIView.animateWithDuration(NSTimeInterval(info.animationDuration),
81+
func keyboardWillDisappear(_ info: KeyboardAppearanceInfo) {
82+
UIView.animate(withDuration: TimeInterval(info.animationDuration),
8383
delay: 0,
8484
options: info.animationOptions,
8585
animations: {

0 commit comments

Comments
 (0)