8

I am working in a Swift project where I have several input fields. I made a custom view for each of the input fields because we use them a lot in the project.

I added IQKeyboardManager to the project. It works really good, and the view gets up according to the active text field.

However, the Next/Previous buttons do not appear. I have tried setting the tags of the text fields in code like this:

slNameField.setTextField("Name", keyboardType: UIKeyboardType.NamePhonePad, image: UIImage(named: "ic_name"))
slNameField.txtField.tag = 101

slEmailField.setTextField("Email", keyboardType: UIKeyboardType.EmailAddress, image: UIImage(named: "ic_email"))
slEmailField.txtField.tag = 102

slLocationField.setTextField("City, Country", keyboardType: nil, image: UIImage(named: "ic_location"))
slLocationField.txtField.tag = 103

Here's some illustrations of the project:

The Signup Screen

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
Ibrahim Yildirim
  • 2,731
  • 2
  • 19
  • 31

5 Answers5

27

I am also stuck into same problem. As mentioned by @sam there is a very helpful demo project of the library.

Solution You only need to select the UIView in which all the textField or UIViews are. And then you just need to change it's class to

"IQPreviousNextView"

And all of the rest will be handled by the library.

Problem screen image

enter image description here

And solution is screen short

enter image description here

Hope it help :). it saved my day.

Abdul Rehman
  • 2,386
  • 1
  • 20
  • 34
7

@Ibrahim Yildirim, If next and previous buttons are not appearing on toolbar this is because textfields must not be in same uiview. they will only appear if all textfields are in same super view .

Nitesh
  • 1,924
  • 21
  • 31
  • 3
    From now you can use '-(void)considerToolbarPreviousNextInViewClass:(Class)toolbarPreviousNextConsideredClass' method to work it with other sublings too. I'll add a demo functionality in repo code. – Mohd Iftekhar Qurashi Apr 20 '15 at 09:35
  • 1
    Download Demo Project from https://github.com/hackiftekhar/IQKeyboardManager... & CustomView has the same solution you want – Sneha Feb 23 '16 at 04:39
2

Please add the line of code in your app delegate file (AppDelegate.swift) in this function: didFinishLaunchingWithOptions. The line of code: IQKeyboardManager.shared.previousNextDisplayMode = .alwaysShow

HafizAnser
  • 553
  • 6
  • 10
  • The best solution is to give class "IQPreviousNextView" to that main view, using your solution will show next previous arrow even if there is only one textField in view. – Hardik Thakkar Mar 06 '19 at 05:46
1

go to the IQUIView+IQKeyboardToolbar.m file and do the following changes

Just change the following method stuff

- (void)addPreviousNextDoneOnKeyboardWithTarget:(id)target previousAction:(SEL)previousAction nextAction:(SEL)nextAction doneAction:(SEL)doneAction titleText:(NSString*)titleText
- (void)addPreviousNextRightOnKeyboardWithTarget:(id)target rightButtonImage:(UIImage*)rightButtonImage previousAction:(SEL)previousAction nextAction:(SEL)nextAction rightButtonAction:(SEL)rightButtonAction titleText:(NSString*)titleText
- (void)addPreviousNextRightOnKeyboardWithTarget:(id)target rightButtonTitle:(NSString*)rightButtonTitle previousAction:(SEL)previousAction nextAction:(SEL)nextAction rightButtonAction:(SEL)rightButtonAction titleText:(NSString*)titleText

find the for next button code in above listed method

//Next button

IQBarButtonItem *next = [[IQBarButtonItem alloc]initWithImage:imageRightArrow style:UIBarButtonItemStylePlain target:target action:nextAction];

//replaces with this code

 IQBarButtonItem *next = [[IQBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStylePlain target:target action:nextAction];

find the for Previous button code in above listed method

//Previous button

IQBarButtonItem *prev = [[IQBarButtonItem alloc] initWithImage:imageLeftArrow style:UIBarButtonItemStylePlain target:target action:previousAction];

//replaces with this code

 IQBarButtonItem *prev = [[IQBarButtonItem alloc] initWithTitle:@"Previous" style:UIBarButtonItemStylePlain target:target action:previousAction];
Fogmeister
  • 76,236
  • 42
  • 207
  • 306
Pushp
  • 1,064
  • 10
  • 18
0

I think you should put this whole hierarchy inside the IQPreviousNextView.

Assign IQPreviousNextView class to UIView (parent view) from storyboard. It will start working.

enter image description here

enter image description here