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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
//
// UIView+IQToolbar.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 <UIKit/UIView.h>
@class UIBarButtonItem;
/**
UIView category methods to add IQToolbar on UIKeyboard.
*/
@interface UIView (IQToolbarAddition)
///-------------------------
/// @name Title and Distance
///-------------------------
/**
If `shouldHidePlaceholderText` is YES, then title will not be added to the toolbar. Default to NO.
*/
@property (assign, nonatomic) BOOL shouldHidePlaceholderText;
/**
`placeholderText` to override default `placeholder` text when drawing text on toolbar.
*/
@property (nullable, strong, nonatomic) NSString* placeholderText;
/**
`drawingPlaceholderText` will be actual text used to draw on toolbar. This would either `placeholder` or `placeholderText`.
*/
@property (nullable, strong, nonatomic, readonly) NSString* drawingPlaceholderText;
/**
Optional target & action to behave toolbar title button as clickable button
@param target Target object.
@param action Target Selector.
*/
-(void)setTitleTarget:(nullable id)target action:(nullable SEL)action;
/**
Customized Invocation to be called on title button action. titleInvocation is internally created using setTitleTarget:action: method.
*/
@property (nullable, strong, nonatomic) NSInvocation *titleInvocation;
///-----------------------------------------
/// @name Customised Invocation Registration
///-----------------------------------------
/**
Additional target & action to do get callback action. Note that setting custom `previous` selector doesn't affect native `previous` functionality, this is just used to notifiy user to do additional work according to need.
@param target Target object.
@param action Target Selector.
*/
-(void)setCustomPreviousTarget:(nullable id)target action:(nullable SEL)action;
/**
Additional target & action to do get callback action. Note that setting custom `next` selector doesn't affect native `next` functionality, this is just used to notifiy user to do additional work according to need.
@param target Target object.
@param action Target Selector.
*/
-(void)setCustomNextTarget:(nullable id)target action:(nullable SEL)action;
/**
Additional target & action to do get callback action. Note that setting custom `done` selector doesn't affect native `done` functionality, this is just used to notifiy user to do additional work according to need.
@param target Target object.
@param action Target Selector.
*/
-(void)setCustomDoneTarget:(nullable id)target action:(nullable SEL)action;
/**
Customized Invocation to be called on previous arrow action. previousInvocation is internally created using setCustomPreviousTarget:action: method.
*/
@property (nullable, strong, nonatomic) NSInvocation *previousInvocation;
/**
Customized Invocation to be called on next arrow action. nextInvocation is internally created using setCustomNextTarget:action: method.
*/
@property (nullable, strong, nonatomic) NSInvocation *nextInvocation;
/**
Customized Invocation to be called on done action. doneInvocation is internally created using setCustomDoneTarget:action: method.
*/
@property (nullable, strong, nonatomic) NSInvocation *doneInvocation;
///------------
/// @name Done
///------------
/**
Helper function to add Done button on keyboard.
@param target Target object for selector.
@param action Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
*/
- (void)addDoneOnKeyboardWithTarget:(nullable id)target action:(nullable SEL)action;
/**
Helper function to add Done button on keyboard.
@param target Target object for selector.
@param action Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param titleText text to show as title in IQToolbar'.
*/
- (void)addDoneOnKeyboardWithTarget:(nullable id)target action:(nullable SEL)action titleText:(nullable NSString*)titleText;
/**
Helper function to add Done button on keyboard.
@param target Target object for selector.
@param action Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param shouldShowPlaceholder A boolean to indicate whether to show textField placeholder on IQToolbar'.
*/
- (void)addDoneOnKeyboardWithTarget:(nullable id)target action:(nullable SEL)action shouldShowPlaceholder:(BOOL)shouldShowPlaceholder;
///------------
/// @name Right
///------------
/**
Helper function to add Right button on keyboard.
@param text Title for rightBarButtonItem, usually 'Done'.
@param target Target object for selector.
@param action Right button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
*/
- (void)addRightButtonOnKeyboardWithText:(nullable NSString*)text target:(nullable id)target action:(nullable SEL)action;
/**
Helper function to add Right button on keyboard.
@param text Title for rightBarButtonItem, usually 'Done'.
@param target Target object for selector.
@param action Right button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param titleText text to show as title in IQToolbar'.
*/
- (void)addRightButtonOnKeyboardWithText:(nullable NSString*)text target:(nullable id)target action:(nullable SEL)action titleText:(nullable NSString*)titleText;
/**
Helper function to add Right button on keyboard.
@param text Title for rightBarButtonItem, usually 'Done'.
@param target Target object for selector.
@param action Right button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param shouldShowPlaceholder A boolean to indicate whether to show textField placeholder on IQToolbar'.
*/
- (void)addRightButtonOnKeyboardWithText:(nullable NSString*)text target:(nullable id)target action:(nullable SEL)action shouldShowPlaceholder:(BOOL)shouldShowPlaceholder;
/**
Helper function to add Right button on keyboard.
@param image Image icon to use as right button.
@param target Target object for selector.
@param action Right button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param shouldShowPlaceholder A boolean to indicate whether to show textField placeholder on IQToolbar'.
*/
- (void)addRightButtonOnKeyboardWithImage:(nullable UIImage*)image target:(nullable id)target action:(nullable SEL)action shouldShowPlaceholder:(BOOL)showPlaceholder;
/**
Helper function to add Right button on keyboard.
@param image Image icon to use as right button.
@param target Target object for selector.
@param action Right button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param titleText text to show as title in IQToolbar'.
*/
- (void)addRightButtonOnKeyboardWithImage:(nullable UIImage*)image target:(nullable id)target action:(nullable SEL)action titleText:(nullable NSString*)titleText;
///------------------
/// @name Cancel/Done
///------------------
/**
Helper function to add Cancel and Done button on keyboard.
@param target Target object for selector.
@param cancelAction Cancel button action name. Usually 'cancelAction:(IQBarButtonItem*)item'.
@param doneAction Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
*/
- (void)addCancelDoneOnKeyboardWithTarget:(nullable id)target cancelAction:(nullable SEL)cancelAction doneAction:(nullable SEL)doneAction;
/**
Helper function to add Cancel and Done button on keyboard.
@param target Target object for selector.
@param cancelAction Cancel button action name. Usually 'cancelAction:(IQBarButtonItem*)item'.
@param doneAction Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param titleText text to show as title in IQToolbar'.
*/
- (void)addCancelDoneOnKeyboardWithTarget:(nullable id)target cancelAction:(nullable SEL)cancelAction doneAction:(nullable SEL)doneAction titleText:(nullable NSString*)titleText;
/**
Helper function to add Cancel and Done button on keyboard.
@param target Target object for selector.
@param cancelAction Cancel button action name. Usually 'cancelAction:(IQBarButtonItem*)item'.
@param doneAction Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param shouldShowPlaceholder A boolean to indicate whether to show textField placeholder on IQToolbar'.
*/
- (void)addCancelDoneOnKeyboardWithTarget:(nullable id)target cancelAction:(nullable SEL)cancelAction doneAction:(nullable SEL)doneAction shouldShowPlaceholder:(BOOL)shouldShowPlaceholder;
///-----------------
/// @name Right/Left
///-----------------
/**
Helper function to add Left and Right button on keyboard.
@param target Target object for selector.
@param leftButtonTitle Title for leftBarButtonItem, usually 'Cancel'.
@param rightButtonTitle Title for rightBarButtonItem, usually 'Done'.
@param leftButtonAction Left button action name. Usually 'cancelAction:(IQBarButtonItem*)item'.
@param rightButtonAction Right button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
*/
- (void)addLeftRightOnKeyboardWithTarget:(nullable id)target leftButtonTitle:(nullable NSString*)leftButtonTitle rightButtonTitle:(nullable NSString*)rightButtonTitle leftButtonAction:(nullable SEL)leftButtonAction rightButtonAction:(nullable SEL)rightButtonAction;
/**
Helper function to add Left and Right button on keyboard.
@param target Target object for selector.
@param leftButtonTitle Title for leftBarButtonItem, usually 'Cancel'.
@param rightButtonTitle Title for rightBarButtonItem, usually 'Done'.
@param leftButtonAction Left button action name. Usually 'cancelAction:(IQBarButtonItem*)item'.
@param rightButtonAction Right button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param titleText text to show as title in IQToolbar'.
*/
- (void)addLeftRightOnKeyboardWithTarget:(nullable id)target leftButtonTitle:(nullable NSString*)leftButtonTitle rightButtonTitle:(nullable NSString*)rightButtonTitle leftButtonAction:(nullable SEL)leftButtonAction rightButtonAction:(nullable SEL)rightButtonAction titleText:(nullable NSString*)titleText;
/**
Helper function to add Left and Right button on keyboard.
@param target Target object for selector.
@param leftButtonTitle Title for leftBarButtonItem, usually 'Cancel'.
@param rightButtonTitle Title for rightBarButtonItem, usually 'Done'.
@param leftButtonAction Left button action name. Usually 'cancelAction:(IQBarButtonItem*)item'.
@param rightButtonAction Right button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param shouldShowPlaceholder A boolean to indicate whether to show textField placeholder on IQToolbar'.
*/
- (void)addLeftRightOnKeyboardWithTarget:(nullable id)target leftButtonTitle:(nullable NSString*)leftButtonTitle rightButtonTitle:(nullable NSString*)rightButtonTitle leftButtonAction:(nullable SEL)leftButtonAction rightButtonAction:(nullable SEL)rightButtonAction shouldShowPlaceholder:(BOOL)shouldShowPlaceholder;
///-------------------------
/// @name Previous/Next/Done
///-------------------------
/**
Helper function to add ArrowNextPrevious and Done button on keyboard.
@param target Target object for selector.
@param previousAction Previous button action name. Usually 'previousAction:(id)item'.
@param nextAction Next button action name. Usually 'nextAction:(id)item'.
@param doneAction Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
*/
- (void)addPreviousNextDoneOnKeyboardWithTarget:(nullable id)target previousAction:(nullable SEL)previousAction nextAction:(nullable SEL)nextAction doneAction:(nullable SEL)doneAction;
/**
Helper function to add ArrowNextPrevious and Done button on keyboard.
@param target Target object for selector.
@param previousAction Previous button action name. Usually 'previousAction:(id)item'.
@param nextAction Next button action name. Usually 'nextAction:(id)item'.
@param doneAction Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param titleText text to show as title in IQToolbar'.
*/
- (void)addPreviousNextDoneOnKeyboardWithTarget:(nullable id)target previousAction:(nullable SEL)previousAction nextAction:(nullable SEL)nextAction doneAction:(nullable SEL)doneAction titleText:(nullable NSString*)titleText;
/**
Helper function to add ArrowNextPrevious and Done button on keyboard.
@param target Target object for selector.
@param previousAction Previous button action name. Usually 'previousAction:(id)item'.
@param nextAction Next button action name. Usually 'nextAction:(id)item'.
@param doneAction Done button action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param shouldShowPlaceholder A boolean to indicate whether to show textField placeholder on IQToolbar'.
*/
- (void)addPreviousNextDoneOnKeyboardWithTarget:(nullable id)target previousAction:(nullable SEL)previousAction nextAction:(nullable SEL)nextAction doneAction:(nullable SEL)doneAction shouldShowPlaceholder:(BOOL)shouldShowPlaceholder;
///--------------------------
/// @name Previous/Next/Right
///--------------------------
/**
Helper function to add ArrowNextPrevious and Right button on keyboard.
@param target Target object for selector.
@param rightButtonTitle Title for rightBarButtonItem, usually 'Done'.
@param previousAction Previous button action name. Usually 'previousAction:(id)item'.
@param nextAction Next button action name. Usually 'nextAction:(id)item'.
@param rightButtonAction RightBarButton action name. Usually 'doneAction:(IQBarButtonItem*)item'.
*/
- (void)addPreviousNextRightOnKeyboardWithTarget:(nullable id)target rightButtonTitle:(nullable NSString*)rightButtonTitle previousAction:(nullable SEL)previousAction nextAction:(nullable SEL)nextAction rightButtonAction:(nullable SEL)rightButtonAction;
/**
Helper function to add ArrowNextPrevious and Right button on keyboard.
@param target Target object for selector.
@param rightButtonTitle Title for rightBarButtonItem, usually 'Done'.
@param previousAction Previous button action name. Usually 'previousAction:(id)item'.
@param nextAction Next button action name. Usually 'nextAction:(id)item'.
@param rightButtonAction RightBarButton action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param titleText text to show as title in IQToolbar'.
*/
- (void)addPreviousNextRightOnKeyboardWithTarget:(nullable id)target rightButtonTitle:(nullable NSString*)rightButtonTitle previousAction:(nullable SEL)previousAction nextAction:(nullable SEL)nextAction rightButtonAction:(nullable SEL)rightButtonAction titleText:(nullable NSString*)titleText;
/**
Helper function to add ArrowNextPrevious and Right button on keyboard.
@param target Target object for selector.
@param rightButtonTitle Title for rightBarButtonItem, usually 'Done'.
@param previousAction Previous button action name. Usually 'previousAction:(id)item'.
@param nextAction Next button action name. Usually 'nextAction:(id)item'.
@param rightButtonAction RightBarButton action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param shouldShowPlaceholder A boolean to indicate whether to show textField placeholder on IQToolbar'.
*/
- (void)addPreviousNextRightOnKeyboardWithTarget:(nullable id)target rightButtonTitle:(nullable NSString*)rightButtonTitle previousAction:(nullable SEL)previousAction nextAction:(nullable SEL)nextAction rightButtonAction:(nullable SEL)rightButtonAction shouldShowPlaceholder:(BOOL)shouldShowPlaceholder;
/**
Helper function to add ArrowNextPrevious and Right button on keyboard.
@param target Target object for selector.
@param rightButtonImage Image icon to use as rightBarButtonItem.
@param previousAction Previous button action name. Usually 'previousAction:(id)item'.
@param nextAction Next button action name. Usually 'nextAction:(id)item'.
@param rightButtonAction RightBarButton action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param titleText text to show as title in IQToolbar'.
*/
- (void)addPreviousNextRightOnKeyboardWithTarget:(nullable id)target rightButtonImage:(nullable UIImage*)rightButtonImage previousAction:(nullable SEL)previousAction nextAction:(nullable SEL)nextAction rightButtonAction:(nullable SEL)rightButtonAction titleText:(nullable NSString*)titleText;
/**
Helper function to add ArrowNextPrevious and Right button on keyboard.
@param target Target object for selector.
@param rightButtonImage Image icon to use as rightBarButtonItem.
@param previousAction Previous button action name. Usually 'previousAction:(id)item'.
@param nextAction Next button action name. Usually 'nextAction:(id)item'.
@param rightButtonAction RightBarButton action name. Usually 'doneAction:(IQBarButtonItem*)item'.
@param shouldShowPlaceholder A boolean to indicate whether to show textField placeholder on IQToolbar'.
*/
- (void)addPreviousNextRightOnKeyboardWithTarget:(nullable id)target rightButtonImage:(nullable UIImage*)rightButtonImage previousAction:(nullable SEL)previousAction nextAction:(nullable SEL)nextAction rightButtonAction:(nullable SEL)rightButtonAction shouldShowPlaceholder:(BOOL)shouldShowPlaceholder;
///-----------------------------------
/// @name Enable/Disable Previous/Next
///-----------------------------------
/**
Helper function to enable and disable previous next buttons.
@param isPreviousEnabled BOOL to enable/disable previous button on keyboard.
@param isNextEnabled BOOL to enable/disable next button on keyboard..
*/
- (void)setEnablePrevious:(BOOL)isPreviousEnabled next:(BOOL)isNextEnabled;
@end