From 88c4e8f2ed2215e6a40228dd5846ca340f0df76c Mon Sep 17 00:00:00 2001 From: hackiftekhar Date: Mon, 4 Apr 2016 12:50:18 +0530 Subject: [PATCH] Added a default IQPreviousNextView --- Demo.xcodeproj/project.pbxproj | 10 ++++++ .../ViewController/CustomViewController.m | 2 +- IQKeyboardManager/IQKeyboardManager.m | 6 +++- .../IQToolbar/IQPreviousNextView.h | 31 +++++++++++++++++++ .../IQToolbar/IQPreviousNextView.m | 28 +++++++++++++++++ .../IQKeyboardManager.swift | 4 +-- .../IQToolbar/IQPreviousNextView.swift | 28 +++++++++++++++++ 7 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 IQKeyboardManager/IQToolbar/IQPreviousNextView.h create mode 100644 IQKeyboardManager/IQToolbar/IQPreviousNextView.m create mode 100644 IQKeyboardManagerSwift/IQToolbar/IQPreviousNextView.swift diff --git a/Demo.xcodeproj/project.pbxproj b/Demo.xcodeproj/project.pbxproj index 9c3e0ba..243d7ca 100755 --- a/Demo.xcodeproj/project.pbxproj +++ b/Demo.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 4C631B161CB24A8E0078E59F /* IQPreviousNextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C631B151CB24A8E0078E59F /* IQPreviousNextView.m */; }; + 4C631B181CB24AAD0078E59F /* IQPreviousNextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C631B171CB24AAD0078E59F /* IQPreviousNextView.swift */; }; 4C7FCC271C6A507E00537BA0 /* IQUIScrollView+Additions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C7FCC261C6A507E00537BA0 /* IQUIScrollView+Additions.m */; }; 4C7FCC291C6A57FF00537BA0 /* IQUIScrollView+Additions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C7FCC281C6A57FF00537BA0 /* IQUIScrollView+Additions.swift */; }; 4CE611A01B98B7250020591A /* DemoObjCUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE6119F1B98B7250020591A /* DemoObjCUITests.m */; }; @@ -102,6 +104,9 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 4C631B141CB24A8E0078E59F /* IQPreviousNextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IQPreviousNextView.h; sourceTree = ""; }; + 4C631B151CB24A8E0078E59F /* IQPreviousNextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IQPreviousNextView.m; sourceTree = ""; }; + 4C631B171CB24AAD0078E59F /* IQPreviousNextView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IQPreviousNextView.swift; sourceTree = ""; }; 4C7FCC251C6A507E00537BA0 /* IQUIScrollView+Additions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "IQUIScrollView+Additions.h"; sourceTree = ""; }; 4C7FCC261C6A507E00537BA0 /* IQUIScrollView+Additions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "IQUIScrollView+Additions.m"; sourceTree = ""; }; 4C7FCC281C6A57FF00537BA0 /* IQUIScrollView+Additions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "IQUIScrollView+Additions.swift"; sourceTree = ""; }; @@ -332,6 +337,7 @@ 4CEC3A661B8CECDF00909DCA /* IQTitleBarButtonItem.swift */, 4CEC3A671B8CECDF00909DCA /* IQToolbar.swift */, 4CEC3A681B8CECDF00909DCA /* IQUIView+IQKeyboardToolbar.swift */, + 4C631B171CB24AAD0078E59F /* IQPreviousNextView.swift */, ); path = IQToolbar; sourceTree = ""; @@ -670,6 +676,8 @@ C0CB62371B8850AE00C33368 /* IQToolbar.m */, C0CB62381B8850AE00C33368 /* IQUIView+IQKeyboardToolbar.h */, C0CB62391B8850AE00C33368 /* IQUIView+IQKeyboardToolbar.m */, + 4C631B141CB24A8E0078E59F /* IQPreviousNextView.h */, + 4C631B151CB24A8E0078E59F /* IQPreviousNextView.m */, ); path = IQToolbar; sourceTree = ""; @@ -865,6 +873,7 @@ 4CEC3A6C1B8CECDF00909DCA /* IQUITextFieldView+Additions.swift in Sources */, C0CB61F41B884F2700C33368 /* TableViewInContainerViewController.swift in Sources */, 4CEC3A741B8CECDF00909DCA /* IQTextView.swift in Sources */, + 4C631B181CB24AAD0078E59F /* IQPreviousNextView.swift in Sources */, C0CB61F91B884F2700C33368 /* WebViewController.swift in Sources */, C0CB61F51B884F2700C33368 /* TextFieldViewController.swift in Sources */, C03C87F91B8DCEC400295DFA /* NavigationTableViewCell.swift in Sources */, @@ -893,6 +902,7 @@ C0CB62051B884FA100C33368 /* CollectionViewDemoController.m in Sources */, C0CB61FF1B884FA100C33368 /* OptionTableViewCell.m in Sources */, C0CB620D1B884FA100C33368 /* SettingsViewController.m in Sources */, + 4C631B161CB24A8E0078E59F /* IQPreviousNextView.m in Sources */, C0CB62461B8850AE00C33368 /* IQBarButtonItem.m in Sources */, C0CB62081B884FA100C33368 /* ExampleTableViewController.m in Sources */, C0CB61FD1B884FA100C33368 /* AppDelegate.m in Sources */, diff --git a/Demo/Objective_C_Demo/ViewController/CustomViewController.m b/Demo/Objective_C_Demo/ViewController/CustomViewController.m index 92ba989..e00da56 100644 --- a/Demo/Objective_C_Demo/ViewController/CustomViewController.m +++ b/Demo/Objective_C_Demo/ViewController/CustomViewController.m @@ -27,7 +27,7 @@ [super viewDidLoad]; returnHandler = [[IQKeyboardReturnKeyHandler alloc] initWithViewController:self]; - + returnHandler.lastTextFieldReturnKeyType = UIReturnKeyDone; // Do any additional setup after loading the view. } diff --git a/IQKeyboardManager/IQKeyboardManager.m b/IQKeyboardManager/IQKeyboardManager.m index 3eb8008..e83f115 100644 --- a/IQKeyboardManager/IQKeyboardManager.m +++ b/IQKeyboardManager/IQKeyboardManager.m @@ -32,6 +32,7 @@ #import "IQUIScrollView+Additions.h" #import "IQUITextFieldView+Additions.h" #import "IQUIViewController+Additions.h" +#import "IQPreviousNextView.h" #import #import @@ -232,9 +233,12 @@ void _IQShowLog(NSString *logString); //Initializing disabled classes Set. strongSelf.disabledDistanceHandlingClasses = [[NSMutableSet alloc] initWithObjects:[UITableViewController class], nil]; strongSelf.enabledDistanceHandlingClasses = [[NSMutableSet alloc] init]; + strongSelf.disabledToolbarClasses = [[NSMutableSet alloc] init]; strongSelf.enabledToolbarClasses = [[NSMutableSet alloc] init]; - strongSelf.toolbarPreviousNextAllowedClasses = [[NSMutableSet alloc] initWithObjects:[UITableView class],[UICollectionView class], nil]; + + strongSelf.toolbarPreviousNextAllowedClasses = [[NSMutableSet alloc] initWithObjects:[UITableView class],[UICollectionView class],[IQPreviousNextView class], nil]; + strongSelf.disabledTouchResignedClasses = [[NSMutableSet alloc] init]; strongSelf.enabledTouchResignedClasses = [[NSMutableSet alloc] init]; diff --git a/IQKeyboardManager/IQToolbar/IQPreviousNextView.h b/IQKeyboardManager/IQToolbar/IQPreviousNextView.h new file mode 100644 index 0000000..9962a16 --- /dev/null +++ b/IQKeyboardManager/IQToolbar/IQPreviousNextView.h @@ -0,0 +1,31 @@ +// +// IQPreviousNextView.h +// https://github.com/hackiftekhar/IQKeyboardManager +// Copyright (c) 2013-16 Iftekhar Qurashi. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +/** + If you need to enable previous/next toolbar button with some complex hierarchy where your textFields are not in same view, then make the top view as IQPreviousNextView. + */ +@interface IQPreviousNextView : UIView + +@end diff --git a/IQKeyboardManager/IQToolbar/IQPreviousNextView.m b/IQKeyboardManager/IQToolbar/IQPreviousNextView.m new file mode 100644 index 0000000..207d115 --- /dev/null +++ b/IQKeyboardManager/IQToolbar/IQPreviousNextView.m @@ -0,0 +1,28 @@ +// +// IQPreviousNextView.m +// https://github.com/hackiftekhar/IQKeyboardManager +// Copyright (c) 2013-16 Iftekhar Qurashi. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "IQPreviousNextView.h" + +@implementation IQPreviousNextView + +@end diff --git a/IQKeyboardManagerSwift/IQKeyboardManager.swift b/IQKeyboardManagerSwift/IQKeyboardManager.swift index 2ff2509..4b1f446 100644 --- a/IQKeyboardManagerSwift/IQKeyboardManager.swift +++ b/IQKeyboardManagerSwift/IQKeyboardManager.swift @@ -801,7 +801,7 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { disabledDistanceHandlingClasses.insert(NSStringFromClass(UITableViewController)) toolbarPreviousNextAllowedClasses.insert(NSStringFromClass(UITableView)) toolbarPreviousNextAllowedClasses.insert(NSStringFromClass(UICollectionView)) - + toolbarPreviousNextAllowedClasses.insert(NSStringFromClass(IQPreviousNextView)) //Workaround to load all appearance proxies at startup let barButtonItem2 = IQTitleBarButtonItem() barButtonItem2.title = "" @@ -1369,7 +1369,7 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { if _textFieldView != nil && _textFieldView?.isAlertViewTextField() == false { //Getting textField viewController - if let textFieldViewController = _textFieldView?.viewController() { + if _textFieldView?.viewController() != nil { // keyboard is already showing. adjust frame. adjustFrame() diff --git a/IQKeyboardManagerSwift/IQToolbar/IQPreviousNextView.swift b/IQKeyboardManagerSwift/IQToolbar/IQPreviousNextView.swift new file mode 100644 index 0000000..dda098a --- /dev/null +++ b/IQKeyboardManagerSwift/IQToolbar/IQPreviousNextView.swift @@ -0,0 +1,28 @@ +// +// IQPreviousNextView.swift +// https://github.com/hackiftekhar/IQKeyboardManager +// Copyright (c) 2013-16 Iftekhar Qurashi. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Cocoa + +class IQPreviousNextView: UIView { + +}