I want to use the UIMenuController to display autofill options for a textfield based on data I already have in my app. The code to update the menu items and fill the textfield when one is selected works fine, but I can't seem to find a way to keep the menucontroller visible while typing. I've tried
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
[[UIMenuController sharedMenuController] setMenuVisible:YES animated:YES];
return YES;
}
but that does nothing. If I put the code to update the menu items before the code to set the menu visible I just end up replacing the first letter in the textfield over and over again and the menu still fails to show.
It's possible that the real problem to fix here is UIMenuController automatically selecting the last word in the text field when it shows, but I haven't found a fix for that either.