A modal UIDatePicker with a semi transparent background. The goal was to keep as simple as possible.
If your project doesn't use ARC: you must add the -fobjc-arc
compiler flag to pr2_ModalDatePicker.m
in Target Settings > Build Phases > Compile Sources.
- Drag the
pr2_ModalDatePicker/pr2_ModalDatePicker
folder into your project.
(see sample Xcode project in /Example)
Import pr2_ModalDatePicker.h, set the delegate, call presentModalwithDate with the date to be the default for the UIDatePicker and finally use the callback delegates
#import <pr2_ModalDatePicker.h>
@interface myViewController : UIViewController <pr2_ModalDatePickerDelegate>
...
pr2_ModalDatePicker *datePicker = [[pr2_ModalDatePicker alloc] initWithNibName:@"pr2_ModalDatePicker" bundle:nil];
datePicker.delegate = self;
NSDate *tdate = [NSDate date];
[datePicker presentModalwithDate:tdate];
And set the delegate callbacks
-(void)pr2datePickerCancel
{
}
-(void)pr2datePickerClear
{
self.lbldate.text = @"";
self.mydate = nil;
}
-(void)pr2datePickerSave:(NSDate *)tdate
{
self.lbldate.text = [self.dateFormatter stringFromDate:tdate];
self.mydate = tdate;
}
Find out who use pr2_ModalDatePicker and add your app to the list.
All source code is licensed under the MIT License.
pr2_ModalDatePicker is brought to you by Pablo Roca Rozas & PR2Studio and contributors to the project. If you have feature suggestions or bug reports, feel free to help out by sending pull requests or by creating new issues. If you're using pr2_ModalDatePicker in your project, attribution would be nice or drop me an email saying hello.