ios - How to use Search Bar for enter text and filter for selection? -
i use textfield enter field of web service.for example entered stationid textfield=35016.
i have total 770 stationid , every station have name. stationid 35016 name new istanbul ltd sti.i want when entered new search bar must list me new istanbul ltd.sti.than select sending web service call.
how can search , select searching field.this code textfield.how change search bar ? thank you.
in .h file
#import <uikit/uikit.h> @interface amdviewcontroller : uiviewcontroller<uitextfielddelegate,nsxmlparserdelegate> @property (unsafe_unretained, nonatomic) iboutlet uitextfield *stationid; @end in .m file
enter code here #import "amdviewcontroller.h" @interface amdviewcontroller () { nsmutabledata *webdata; nsxmlparser *xmlparser; nsmutablestring *retornosoap; bool teveretorno; @end @implementation amdviewcontroller @synthesize stationid; } -(ibaction)calculartemperatura:(uibutton *)sender{ nsstring *mensagemsoap= [nsstring stringwithformat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<soap:envelope xmlns:xsi=\"http://www.w3.org/2001/xmlschema-instance\" xmlns:xsd=\"http://www.w3.org/2001/xmlschema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" "<soap:body>\n" "<details xmlns=\"http://tempuri.org/\">\n" "<stationid>%@</stationid>\n" "<stationname>%@</stationname>\n" //stationname here in web sevrice "</details>\n" "</soap:body>\n" "</soap:envelope>\n",staionid.text]; nslog(@"soap msg = \n%@\n\n", mensagemsoap); nsurl *url = [nsurl urlwithstring:@"http://webservice/sample.asmx"]; nsmutableurlrequest *therequest = [nsmutableurlrequest requestwithurl:url]; nsstring *tamanhomensagem = [nsstring stringwithformat:@"%d", [mensagemsoap length]]; [therequest addvalue:@"text/xml; charset=utf-8" forhttpheaderfield:@"content-type"]; [therequest addvalue: @"http://tempuri.org/details" forhttpheaderfield:@"soapaction"]; [therequest addvalue:tamanhomensagem forhttpheaderfield:@"content-length"]; [therequest sethttpmethod:@"post"]; [therequest sethttpbody:[mensagemsoap datausingencoding:nsutf8stringencoding]]; nsurlconnection *conexao = [[nsurlconnection alloc] initwithrequest:therequest delegate:self]; if(conexao){ webdata = [nsmutabledata data]; }else{ nslog(@"connection error."); } } -(void)parser:(nsxmlparser *)parser didstartelement:(nsstring *)elementname namespaceuri:(nsstring *)namespaceuri qualifiedname:(nsstring *)qname attributes:(nsdictionary *)attributedict{ if ( [elementname isequaltostring:@"stationid"] ) { if (!retornosoap) { retornosoap = [[nsmutablestring alloc] init]; } teveretorno = yes; } } - (void)parser:(nsxmlparser *)parser didendelement:(nsstring *)elementname namespaceuri: (nsstring *)namespaceuri qualifiedname:(nsstring *)qname{ if ( [elementname isequaltostring:@"stationid"] ) { staiontotalsalestodaylabel.text = retornosoap; retornosoap = nil; teveretorno = no; }
you have use uisearchbar control , delegate methods. here link may you
Comments
Post a Comment