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

johnnybluejeans

macrumors 6502
Original poster
Jan 16, 2006
294
0
New York, NY
Is there a way to override autocomplete such that I can inject my own suggestions from a list? Basically looking for a way to help users quickly fill in a field based on commonly used values.
 

Pring

macrumors 6502
Sep 17, 2003
310
0
Check out UITextFieldDelegate's textField:shouldChangeCharactersInRange:replacementString: method.
 

johnnybluejeans

macrumors 6502
Original poster
Jan 16, 2006
294
0
New York, NY
I've looked into this. While this event gives me a heads up as to the next character getting entered, it still doesn't provide me with a way to pop up or override the autosuggestion feature.

Check out UITextFieldDelegate's textField:shouldChangeCharactersInRange:replacementString: method.
 

Niiro13

macrumors 68000
Feb 12, 2008
1,719
0
Illinois
I've looked into this. While this event gives me a heads up as to the next character getting entered, it still doesn't provide me with a way to pop up or override the autosuggestion feature.

They're basically saying to turn off the autocomplete textfield.autocorrectionType = UITextAutocorrectionNone. (I think)

Basically, you're going to create your own autocorrection feature.

Then use that method to check for the word. So in the method you'd be like:

Code:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
if ([textField.text isEqualToString:@"fir"])
if (![string isEqualToString:@"e"]) {
// code to pop up a subview that has the word "fire" in it.
}
}

Then you could do many things. When someone hits the enter key, you can check to see if the view is up. If it is, then replace the word in the textField. If someone hits the spacebar (basically, if the replacement string is equal to a space) and the view is up, then replace the word.

It's tedious, but it's your only choice.
 

johnnybluejeans

macrumors 6502
Original poster
Jan 16, 2006
294
0
New York, NY
I've also thought about using this approach.. I guess my fear is that Apple will reject an application that mimics their autocomplete functionality. In their own words this can be "confusing to the user."
 

Pring

macrumors 6502
Sep 17, 2003
310
0
I hate this culture of fear in Apple :( I totally understand why you feel that way but I'd hope Apple would be more sensible than that.

Anyway, my app Alphonetic has a feature that's totally built about using that method to substitute in new autocompletions. The phrase builder uses that to swap the character 'A' for 'Alpha' and so on. It got approved by Apple so hopefully that's the kind of thing they don't mind.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
@Pring, can you show a screenshot of your "subview"? What superview do you add it to? Is it rectangular or some other shape?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.