Methods UITextField of UISearchBar return nil
I've got a searchBar wich sometimes has text filled in. I would like to
set the cursor of the underlying UITextField to a certain position. I
Already have a pointer that is not nil to the UITextField:
UITextField *searchField = [self.searchBar valueForKey:@"_searchField"];
And I fill in the text:
self.searchBar.text = addressToComplete.description;
And checked if the UITextField text is filled in and it is. Still, all the
methods regarding UITextPosition and UITextRange return nil:
UITextRange *selectedRange = [searchField selectedTextRange];
//selectedRange = nil
UITextPosition *newPosition = [searchField
positionFromPosition:selectedRange.start
offset:addressToComplete.street.length]; //newPosition = nil
UITextRange *newRange = [searchField textRangeFromPosition:newPosition
toPosition:newPosition]; //newRange = nil
I'm wondering what am I doing wrong here?
No comments:
Post a Comment