I'm going crazy. The logic seems right, yet that damn DONE button keeps appearing. Even when I trace it gets to a point on the Default Pad where it follows through and ignores the DONE methods...then displays HEX so I have to fast forward...
Thanks in advance. This has been niggling me too long.
__________________ iPhone Apps: Who SAid™, iFRICA™, iFA™, iReceipt™,eCash™
I would start putting some NSLog, to understand if addDone has the right value in each method. (in case it is modified by someone in some case)
Hi Danny,
I tried that. I have logged everywhere. Trace through and all responders, whether addDone has the correct value at each step and it does, which means the text delegate is setting addDone correctly.
The weirdest is it traces through and ignores the DONE button creation based on the field I am editing (which uses the Default pad). I then pop to the simulator at the end of the method - pointer on closing } and the Default pad still has no DONE button.
At this point when I step through it runs into assembler stuff. So I then fast forward on the debugger and the DONE button redisplays.
I'm baffled with this. The code looks right to me.
__________________ iPhone Apps: Who SAid™, iFRICA™, iFA™, iReceipt™,eCash™
mmm.......set up a project, I can't grant to download and try, but maybe can be usefull also to others that want to help.
I have now switched off the DONE button at every stage. I have addDone logs throughout and they all say addDone is NO. The button does not display until I fast forward in the debugger once it has processed through keyboardDidShow (which is the very last method processed before it displays). All the way to that point addDone is NO.
This DONE button topic is a widespread topic. I think the lazy answer is to create a big button and just press anywhere on the screen. I tend to be emphatic about the user's experience and so believe these small things must be sorted.
No one seems to have a final solution. I'm trying one where I have Numeric pad and other Pads in the same view controller, plus I have a private delegate doing a whole bunch. If we get this right, then I would be happy to present the final solution and close the DONE button topic until Apple finally embeds this into the core SDK build.
__________________ iPhone Apps: Who SAid™, iFRICA™, iFA™, iReceipt™,eCash™
ok, however i mean a project sample of the not working project.....so that if someone want try to help you, can do it.
Ok...I slapped together a quick project using the same code (cut and paste) and it works perfectly. Mystery!
For those of you who need a DONE button to work on Numpad with a view that also uses other keyboards just let me know and I will email the code. The code above does work, but sometimes it is better having it in a project. I will remain on this thread so I can help.
Thanks Dany!!!...now I need to find my gremlin.
__________________ iPhone Apps: Who SAid™, iFRICA™, iFA™, iReceipt™,eCash™
Last edited by ManWithMask; 05-12-2011 at 12:30 PM.
It worked because my 1st field I clicked was a numpad.
I decided to add 2 text fields.
The keyboard responds (NSNotification responder) on the first field I enter and after that entirely ignores the NSNotification. It is like they switched off.
I can email the project. Perhaps there is something you can work out. I have checked and I'm not releasing the observers (or at least I think so).
__________________ iPhone Apps: Who SAid™, iFRICA™, iFA™, iReceipt™,eCash™
I think I may have the culprit nailed down. All the DONE key solutions work, because the samples I have seen only have one field on the screen.
In the real world this is not the case.
NSNotification:UIKeyboardDidShowNotification only responds once on a view the first time it sees a keyboard. It does not respond each time you enter a new field and the keyboard pops up again.
This might require an entirely different strategy (like when is Apple going to fix this).
Thoughts please?
__________________ iPhone Apps: Who SAid™, iFRICA™, iFA™, iReceipt™,eCash™
Si. That was the first thing I did. Removed the NSNotifier and called the method to create the button if editing the numpad fields else return. I'm still playing with that option. I have in the mean time added another post, which has the code.
__________________ iPhone Apps: Who SAid™, iFRICA™, iFA™, iReceipt™,eCash™
what's the problem to set addDone = YES; if the textfield is one of the numpad and addDone =NO; if not it is.
Check the new post I created.
The problem is that the UIKeyboardDidShowNotification only responds the first time a keyboard is displayed in a view. After that it ignores (or at least my code works that way - but I think it is right).
All the Done samples about only do it with one field. The problem is when you have several and they are not all num pads. So we user clicks on another num pad if the first field you brought up the keyboard was a numpad, then it looks perfect. However, clicking on another pad will also bring up the Done (because it does not respond to the notification method again).
__________________ iPhone Apps: Who SAid™, iFRICA™, iFA™, iReceipt™,eCash™
I have managed to get the solution working 99% using NSNotifications. I tried the text delegate, but ran into more problems.
The options are:
1. User click on the DONE buttons for either pad to close that pad each time they move from field to field, then it works 100%.
2. User clicks on the next field without first clicking on the DONE button, then the NSNotification will not observe any keyboard changes and then it will not work.
Perhaps you can see a way around this. I have reached my limits.
I am attaching the complete code.
__________________ iPhone Apps: Who SAid™, iFRICA™, iFA™, iReceipt™,eCash™
This dismissed the keyboard so the NSNotifier fires up when user moves between fields.
Better, but still not 100%. Problem with using TOUCH DOWN is that it does get confused if you have a UIScroller embedded over the fields and so does not pick up the TOUCH DOWN. I am at least getting it to respond to the keyboard notifications each time because before when I moved between fields without hitting the DONE button it was not.
The thing is UIScroller is going to be used by many, so it is not perfect.
Will be nice to see if you get closer to a solution.
__________________ iPhone Apps: Who SAid™, iFRICA™, iFA™, iReceipt™,eCash™
Well done Dany! Thanks so much for your help. This time around we are at 100%. I did a lot of clicking just to make sure the memory leaks are patched.
Delegate works definitely best at retaining and removing the DONE button because these will always be fired up when the cursor hits these fields, whereas that is not the case with NSNotifications, unless you have removed the keyboard, else it assumes it is there and so why do anything.
I also added a UIScroller just to show how nicely it works. The only XIB action we need to attach is for when user presses the DONE button on the default keyboard (nothing new and there are plenty of tutorials on that subject).
Finally I think we can say we have the best solution for the DONE button on the number pad because:
1. It works across all iOS versions;
2. Works with textfields;
3. Works with many fields;
4. Works with UIScroller embedded because their is no need for TOUCH DOWN.
Thanks Dany once again!
For the rest, I am attaching the complete sample application. Hopefully you will all find the answers sooner than I did.
__________________ iPhone Apps: Who SAid™, iFRICA™, iFA™, iReceipt™,eCash™
Well done Dany! Thanks so much for your help. This time around we are at 100%. I did a lot of clicking just to make sure the memory leaks are patched.
Delegate works definitely best at retaining and removing the DONE button because these will always be fired up when the cursor hits these fields, whereas that is not the case with NSNotifications, unless you have removed the keyboard, else it assumes it is there and so why do anything.
I also added a UIScroller just to show how nicely it works. The only XIB action we need to attach is for when user presses the DONE button on the default keyboard (nothing new and there are plenty of tutorials on that subject).
Finally I think we can say we have the best solution for the DONE button on the number pad because:
1. It works across all iOS versions;
2. Works with textfields;
3. Works with many fields;
4. Works with UIScroller embedded because their is no need for TOUCH DOWN.
Thanks Dany once again!
For the rest, I am attaching the complete sample application. Hopefully you will all find the answers sooner than I did.
PROBLEM...
There is still a scenario, which does not work with this code. If user touches number field followed by another number field and then goes to a text field, then the DONE key is still visible.
__________________ iPhone Apps: Who SAid™, iFRICA™, iFA™, iReceipt™,eCash™
yes, really i thinked about it....because there is a double DONE button and only 1 remove.....so just check if already added, if so, don't add it again.