datePicker的简单使用方法:(注意连线)
- (IBAction)buttonpressed:(id)sender {
NSDate *selected = [datePicker date]; NSTimeZone *timeZone3 = [NSTimeZone timeZoneForSecondsFromGMT:3600*8]; NSDateFormatter *formatter3 = [[NSDateFormatter alloc] init]; [formatter3 setTimeZone:timeZone3]; [formatter3 setDateFormat:@"G YYYY-MM-dd EEEE aa HH:mm:ss Z"]; NSString *dateString = [formatter3 stringFromDate:selected]; NSString *message = [[NSString alloc]initWithFormat:@"The date and time you selected is : %@",dateString]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Date and Time Selected" message:message delegate:nil cancelButtonTitle:@"Yes,I did" otherButtonTitles: nil]; [alert show]; [alert release]; [message release];}