0
我使用textfield輸入我的web服務的字段。例如,我輸入了StationID textfield = 35016。如何使用搜索欄輸入文本和過濾器進行選擇?
我有770個StationID,每個站都有一個名稱。 stationId 35016的名稱是New Istanbul LTD STI.I當我進入New搜索欄時,它必須列出給我新的Istanbul LTD.STI.Than,然後我會選擇發送Web服務呼叫。
我該如何做搜索和選擇搜索field.This代碼Textfield.How更改爲搜索欄?謝謝。
在.m文件
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 is 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;
}
這是搜索和顯示table.I想從texfield – Mhmt 2013-05-10 12:56:54
可以使用編輯Changed事件或編輯開始事件的web服務搜索的鏈接。在這些事件中添加您的搜索查詢代碼 – 2013-05-10 13:13:34
@ Jay Gajjar您能告訴我任何樣本嗎?我不知道如何使用。 – Mhmt 2013-05-10 13:16:29