DatePickerViewController.m
上传用户:jjjjag8
上传日期:2017-04-17
资源大小:1443k
文件大小:1k
源码类别:

iPhone

开发平台:

MultiPlatform

  1. //
  2. //  DatePickerViewController.m
  3. //  Pickers
  4. //
  5. //  Created by Jeff LaMarche on 7/7/08.
  6. //  Copyright 2008 __MyCompanyName__. All rights reserved.
  7. //
  8. #import "DatePickerViewController.h"
  9. @implementation DatePickerViewController
  10. @synthesize datePicker;
  11. -(IBAction)buttonPressed:(id)sender
  12. {
  13. NSLog(@"Button Pressed");
  14. NSDate *selected = [datePicker date];
  15. NSString *message = [[NSString alloc] initWithFormat:@"The date and time you selected is: %@", selected];
  16. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Date and Time Selected" message:message delegate:nil cancelButtonTitle:@"Yes, I did." otherButtonTitles:nil];
  17. [alert show];
  18. [alert release];
  19. [message release];
  20. }
  21. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
  22. if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
  23. // Initialization code
  24. }
  25. return self;
  26. }
  27. - (void)viewDidLoad {
  28. NSDate *now = [NSDate date];
  29. [datePicker setDate:now animated:YES];
  30. }
  31. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  32. // Return YES for supported orientations
  33. return (interfaceOrientation == UIInterfaceOrientationPortrait);
  34. }
  35. - (void)didReceiveMemoryWarning {
  36. [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
  37. // Release anything that's not essential, such as cached data
  38. }
  39. - (void)dealloc {
  40. [datePicker release];
  41. [super dealloc];
  42. }
  43. @end