iPhone Development – Learning to use a date spinner (date picker)
The imfamous iPhone date reel/spinner/picker is easily implemented into your own custom iPhone app. The Class Reference for the UIDatePicker is available here.
I would like to share a simple project I made to help understand the UIDate Picker. This was based on the iPhone Developers Cookbook Example.
The project is a simple date spinner which once it sets on a date sends a UIAlert of the date. It outlines well the UIDate Picker and an UIAlert. The project is extremely simple, but hopefully someone will find it useful.
UIDatePicker Code:
// Add the picker
float height = 216.0f;
pickerView = [[UIDatePicker alloc] initWithFrame:CGRectMake(0.0f, 416.0f - height, 320.0f, height)];
pickerView.datePickerMode = UIDatePickerModeDate;
[pickerView addTarget:self action:@selector(changedDate:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:pickerView];
[pickerView release];
UIAlert Code:
NSString *message = caldate;
UIAlertView *baseAlert = [[UIAlertView alloc] initWithTitle:@"" message:message delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[baseAlert show];
Project Screenshots
Project File
References
- iPhone Cookbook


