Way to override autocomplete?

Discussion in 'iOS Programming' started by johnnybluejeans, Oct 2, 2008.

  1. johnnybluejeans macrumors 6502

    Joined:
    Jan 16, 2006
    Location:
    New York, NY
    #1
    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.
     
  2. Pring macrumors 6502

    Joined:
    Sep 17, 2003
    #2
    Check out UITextFieldDelegate's textField:shouldChangeCharactersInRange:replacementString: method.
     
  3. johnnybluejeans thread starter macrumors 6502

    Joined:
    Jan 16, 2006
    Location:
    New York, NY
    #3
    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.

     
  4. Niiro13 macrumors 68000

    Joined:
    Feb 12, 2008
    Location:
    Illinois
    #4
    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.
     
  5. johnnybluejeans thread starter macrumors 6502

    Joined:
    Jan 16, 2006
    Location:
    New York, NY
    #5
    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."
     
  6. Pring macrumors 6502

    Joined:
    Sep 17, 2003
    #6
    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.
     
  7. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #7
    @Pring, can you show a screenshot of your "subview"? What superview do you add it to? Is it rectangular or some other shape?
     

Share This Page