2 개의 텍스트 입력란과 1 개의 버튼이 있습니다. 나는 입력 한 텍스트 필드를 사용했지만 날짜 선택 도구를 사용해야합니다.텍스트 필드 대신 날짜 선택 도구를 사용하는 방법은 무엇입니까?
이 코드는 텍스트 필드에 날짜를 입력하고 일부 필드를 라벨에 표시합니다.이 코드 대신 날짜 선택기를 어떻게 변경합니까?
ViewController.h
@interface ViewController : UIViewController <NSXMLParserDelegate>
- (IBAction)Send:(UIButton *)sender;
@property (unsafe_unretained, nonatomic) IBOutlet UITextField *Date1;
@property (unsafe_unretained, nonatomic) IBOutlet UITextField *Date2;
//will here define for date picker
@end
ViewController.m
@interface ViewController(){
NSMutableData *webData;
NSXMLParser *xmlParser;
NSMutableString *returnSOAP;
BOOL tReturn;
}
@end
@implementation ViewController
@synthesize Date1,Date2;
- (IBAction)Send:(UIButton *)sender{
NSString *msgSOAP= [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"
"<ShowDetails xmlns=\"http://tempuri.org/\">\n"
"<date1>%@</date1>\n"
"<date2>%@</date2>\n"
"</ShowDetails>\n"
"</soap:Body>\n"
"</soap:Envelope>\n",Date1.text,Date2.text];
NSLog(@"SOAP Resulr = \n%@\n\n", msgSOAP);
NSURL *url = [NSURL URLWithString:@"http://webservice/service.asmx"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *dnMsg = [NSString stringWithFormat:@"%d", [msgSOAP length]];
[theRequest addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"http://tempuri.org/ShowDetails"
forHTTPHeaderField:@"SOAPAction"];
[theRequest dnMsg forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[msgSOAP dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:theRequest
delegate:self];
if(con){
webData = [NSMutableData data];
}else{
NSLog(@"Connection Error.");
}
}
감사합니다
당신이 당신의 날짜에 원하는 형식은 무엇입니까? datePicker를 표시하려면 textField의 inputView 및 inputAccessoryView를 사용해야합니다. 날짜를 선택하고 dateFormatter를 사용하여 변환 한 다음 textField의 텍스트로 설정하십시오. – Anupdas