Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
Is there a way that I can disable all the UITextFields except for the one that is selected until the user presses the return to dismiss the keyboard.

My code works great but if the user make more then 1 change to a textfield before pressing return it only replaces the last change they made to the Array index. I have been scratching my head trying find a way to do this.

Any ideas, web links or Doc's?

Thanks
 
Is there a way that I can disable all the UITextFields except for the one that is selected until the user presses the return to dismiss the keyboard.

My code works great but if the user make more then 1 change to a textfield before pressing return it only replaces the last change they made to the Array index. I have been scratching my head trying find a way to do this.

Any ideas, web links or Doc's?

Thanks

You can certainly setEnabled:NO on fields... but this really isn't what you want. (The docs for this is UIControl, since UITextField inherits from that)

But anyway, back to why you don't want to do that. You actually DO want to allow the user to make any changes they want to any text view and then accept what they entered last as their entry (because... that's what the user did and what they want, so why would you prevent them from doing this?)

Make sense?
 
The issue that I am having is that when ever the user hits the return key the edited text value replaces the value at an index number of an NSMutableArray. If he makes more then 1 change only the last one is recorded and the other default back to the original numbers.

If I can lock the user out of being able to click any other textFields until he confirms his change this solves the problem.
 
The issue that I am having is that when ever the user hits the return key the edited text value replaces the value at an index number of an NSMutableArray. If he makes more then 1 change only the last one is recorded and the other default back to the original numbers.

If I can lock the user out of being able to click any other textFields until he confirms his change this solves the problem.

No, it would just make your code work, and would frustrate your users. On the iPhone/iPad, a user's tolerance for restriction is next to zero. If you frustrate your users by forcing them to unnaturally have to hit return they'll just abandon your app.

Really you need to correct the short-falling in your code.
 
multiple text fields

Just wanted to confirm that if you want users to be able to move across multiple text fields making entries without touching done/return on the keyboard it can be done but I'm not using a tableview. I have a todo list in a scrollview with 30 entries which users can freely type into and then move to another field without dismissing the keyboard. - (BOOL)textFieldShouldReturn: saves away any entry and I don't lose any content.
 
I think a better solution in your code would be making it so that the text fields have a delegate set up to respond whenever the text changes, not just when the return key is hit.

If you insist on not allowing the user to change multiple fields at once, another solution could be making a modal view that pops up when they tap the field and the modal view is where they make the changes.

I don't endorse the second possibility I suggest at all. I've seen apps that do this before, and they annoy me a good deal, but at least it's something that has been done before and so would seem more natural to users than having all the other text fields disabled until they hit return on the one they've already selected.
 
It is so frustrating. I have probably spent 100 hours writing this class and learning a lot as I do it. I tore it apart once and started over when I began having big issues that I could not explain easily. The new version is less cod and works great except for the user making more then 1 change to existing entries. If the user does not have freedom to click around I can see that as a negative thing now. I do use the (BOOL)textFieldShouldReturn: method and that is where I have the majority of code to write to my arrays.

Perhaps I could use the - (void)textFieldDidEndEditing: to check if the textfields value has changed. If it has I might then store the the new TextField values, the row and column (column 1 2 3 to array 1 2 or 3). Then when the user hits the return button all the information is written to the at once in the (BOOL)textFieldShouldReturn: code I have.

Thanks for the suggestions.
 
It is so frustrating. I have probably spent 100 hours writing this class and learning a lot as I do it. I tore it apart once and started over when I began having big issues that I could not explain easily. The new version is less cod and works great except for the user making more then 1 change to existing entries. If the user does not have freedom to click around I can see that as a negative thing now. I do use the (BOOL)textFieldShouldReturn: method and that is where I have the majority of code to write to my arrays.

Perhaps I could use the - (void)textFieldDidEndEditing: to check if the textfields value has changed. If it has I might then store the the new TextField values, the row and column (column 1 2 3 to array 1 2 or 3). Then when the user hits the return button all the information is written to the at once in the (BOOL)textFieldShouldReturn: code I have.

Thanks for the suggestions.

What you're missing is that these methods are not invoked the way you think they should. You think that when you switch fields it will send you something and it doesn't. Think instead of implementing textField:shouldChangeCharactersInRange:replacementString: to track changes the user makes to the various fields and textFieldDidEndEditing for when they're done. The majority of the work is done by the former method.

(You may get a textFieldShouldBeginEditing: when the user switches among textFields, but I'm not sure)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.