Tuesday, 15 March 2011

iphone - How to create action to search button in keyboard? -



iphone - How to create action to search button in keyboard? -

i have 3 text fields in 1 page, when textfield empty, keyboard should show homecoming keyboard, otherwise should show search, , clicking on search button need go view controller. can explain sample code?

set delegate of uitextfield , them implement delegate function

to show search , return key

- (void)textfielddidbeginediting:(uitextfield *)textfield { if ([textfield.text isequaltostring:@""]) { textfield.returnkeytype=uireturnkeydefault; } else{ textfield.returnkeytype=uireturnkeysearch; } }

coding on keyboard homecoming button

-(bool) textfieldshouldreturn:(uitextfield *)textfield { if (textfield.returnkeytype==uireturnkeydefault) { //your homecoming key code } else if(textfield.returnkeytype==uireturnkeysearch) { //your search key code } }

iphone search iphone-sdk-3.0

No comments:

Post a Comment