-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TextField Previous and Next not appear #549
Comments
Prev Next will appear if there are more than 1 sibling textField |
I add 3 textField but not appear, when add to self.view they appeared |
You added 3 textField but doesn't appear? when you added to self.view they appeared? didn't understand. Both are looking like same statement. |
Is there any way to get IQKeyboardManager to search up and down the view hierarchy? I have a view laid out with multiple nested UIStackViews (a common use case for stack views) and I can't find a way to get the next rev to appear. Would be awesome to have a way of manually setting them like a delegate callback "nextTextFieldForCurrentTextField" etc... Or even just an array of text fields for the manager to iterate through.
Etc... If you can point me in the right direction in the project I'd be happy to update it and make a pull request. |
I added a couple lines of code... not in a PR yet but possibly soon. Anyway...
and a new property...
And all I need to do is...
and it works fine. Just need to set it back to nil in @liufengyu you may be able to use the same thing here to force the next/prev buttons to appear. |
That's a bit of extra manual management and need to take extra care in viewWillDisappear. This is not we want in a library, @oliverfoggin We may need to come with a generic solution which should do the trick without any external textField references. |
@hackiftekhar true. But in this case the automatic part of the library isn't working. You could make it recursively search for all UITextFields but not sure how that would perform (also a possibility of getting text fields that currently aren't visible etc...) This was a quick hack for me and works until something better is done. |
Yeah you totally correct It's a quick hack this is why it's not suitable for a open source library used by many developers. We may need to come up with a generic solution by combining toolbarManageBehaviour with IQPreviousNextView. |
@hackiftekhar I didn't say it was suitable. I merely pointed out how I had forced it to work. I had 20 minutes to get this working. I wouldn't have submitted this but something similar. Anyway, it is working for me now and if I remove the update then it doesn't work so I'm happy. Do whatever you think is necessary. |
@hackiftekhar please could you explain what the I have added this...
But it is still not showing prev or next arrows. Going to have to put my hack in again to fix this. Thanks |
This property treats all it's inner subviews as part of siblings to navigate through. I'm not sure why it doesn't work for you. |
@hackiftekhar I think the problem (possibly) is that it only goes one level deep. My view hierarchy is...
So it would need to go up twice and down twice to find the next/prev text field. It's actually more complex than this but it shows as an example. As much as I'd love for there to be an automatic way to solve this I think it would be much easier to add a manual method to override it like my example above. |
ok, I think you should put all this hierarchy inside IQPreviousNextView (On top of the most top UIStackView), so it will find all inner textFields. |
@hackiftekhar ah! That works! Thanks :D |
What to do in objective c for same problem ? |
Things are same for ObjC and Swift, so you can follow same approach in both languages. |
Thanks for reply. but it is giving me following error. |
@viral105 please check solution regarding |
@hackiftekhar I am not using UIStackView but my textfields are subview of different UIView. So where should I found the code for that ? |
You could check CustomView Example in demo or you can read documentation here:- |
@viral105 the solution (that was mentioned long ago) is to use the IQPreviousNextView and put all your text fields inside that. This is a very easy solution and works. I'm not even sure what your code... Just put the controls inside the |
Its Done. @oliverfoggin comment helped me to resolve my problem. |
I've 5 textFileds in a single StackView and previous and next button is not working. Although I've written IQKeyboardManager.sharedManager().previousNextDisplayMode = .alwaysShow in viewWillApear but still not working. |
Your all textField might not be in same superview I think? |
overrideIteratingTextFields works for me. |
I'm curious why the Author thinks embedding views in a IQPreviousNextView is not considered too much manual work but sticking references in an array is considered too much manual work. For a library presenting itself as automatic i think buggering around with classes in a storyboard is more invasive and prone to future problems than handling a manual override in your code. It's certainly easier to remove the code based condition and the compiler will catch problems for you at that level. Putting custom things in a storyboard is a great way to give someone a runtime crash in the future and you also cannot document it for anyone coming past making changes to the code. @oliverfoggin presents a really simple solution that will work for any sort of complicated layout where you have the references available, and in 99% of the cases you will have the references available because input fields without references are not super useful. Regardless, the IQPreviousNextView solution does work, but now I have had to pollute one of our libraries with another dependency just to add it into the storyboard, and write a note explaining the footgun that's now hidden in one of the libraries in an inobvious way that the compiler won't catch. |
on ViewController when I add TextField to a subView of self.view
The text was updated successfully, but these errors were encountered: