我有 2 个文本字段和 1 个按钮。我使用文本字段输入日期,但我必须使用日期选择器。
此代码用于将日期输入到文本字段并将某些字段显示到标签。如何更改日期选择器此代码?
视图控制器.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
视图控制器.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.");
}
}
谢谢