Custom Keyboard Text Fully Replacing The Text in a UISearchBar rather than Adding to it [iOS] -


i have simple application has had it's premise changed. used user tap on text field , come custom toolbar above keyboard, allowing user select custom buttons add text in text field. if user typed in john's , pressed wedding button, text field add wedding end john's wedding.

i have changed ui incorporate new table view controller when user selects text field because have autocompleting occurring making easier user. have brought keyboard forward now, instead of custom button adding text in search bar, replacing it.

so if type john in search bar , press wedding in custom keyboard, search bar's text gets replaced john wedding. not ideal , need fix this.

here code:

-(void)configurekeyboardtoolbars {     uitoolbar *eventtoolbar = [[uitoolbar alloc] initwithframe:cgrectmake(0.0f, 0.0f,                                                                           self.view.window.frame.size.width, 44.0f)];     eventtoolbar.tintcolor = [uicolor colorwithred:0.6f green:0.6f blue:0.64f alpha:1.0f];     eventtoolbar.translucent = no;     eventtoolbar.items =   @[ [[uibarbuttonitem alloc] initwithtitle:@"wedding"                                                                style:uibarbuttonitemstylebordered                                                               target:self                                                               action:@selector(barbuttonaddtext:)],      // text field, line below used be:     self.eventtextfield.inputaccessoryview = eventtoolbar;      self.eventaddsearchbar.inputaccessoryview = eventtoolbar; 

this calls method below:

// method responds tool bar buttons being pressed -(ibaction)barbuttonaddtext:(uibarbuttonitem*)sender {     if (self.eventaddsearchbar.isfirstresponder)     {         self.eventaddsearchbar.text = sender.title;     } } 

this used be:

// method responds tool bar buttons being pressed -(ibaction)barbuttonaddtext:(uibarbuttonitem*)sender {     if (self.eventtextfield.isfirstresponder)     {         [self.eventtextfield inserttext:sender.title];     } } 

so searchbar not have inserttext method , can understand replacing text on it; not sure how go adding custom toolbar word end (or beginning) of text in search bar depending on user types.

if user presses button before typing, wedding john , if user presses after (more likely) should john's wedding, or whatever user types.

any assistance go long way!

maybe i'm misunderstanding, couldn't this:

nsstring *text = self.eventaddsearchbar.text; self.eventaddsearchbar.text = [text stringbyappendingformat:@" %@", sender.title]; 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -