TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Sep 2017 |
Maintained by gameleon-dev.
This port was made so that the features of the DatePickerDialog could be used in a Objective-C project without having to import the Swift runtime in your app binary (which can increase the app binary size quite a bit)
DatePickerDialog is an iOS drop-in class that displays an UIDatePicker within an UIAlertView.
DatePickerDialog works on iOS 8, 9 and 10. It depends on the following Apple frameworks, which should already be included with most Xcode templates:
LSLDatePickerDialog.h
and LSLDatePickerDialog.m
in your project.#import "LSLDatePickerDialog.h"
@implementation ViewController {
-(void)openDatePicker {
LSLDatePickerDialog *dpDialog = [[LSLDatePickerDialog alloc] init];
[dpDialog showWithTitle:@"DatePicker" doneButtonTitle:@"Done" cancelButtonTitle:@"Cancel"
defaultDate:[NSDate date] minimumDate:nil maximumDate:nil datePickerMode:UIDatePickerModeDate
callback:^(NSDate * _Nullable date){
if(date)
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterMediumStyle];
NSLog(@"Date selected: %@",[formatter stringFromDate:date]);
}
}
];
}
Example initialization without 'Cancel' button:
LSLDatePickerDialog *dpDialog = [[LSLDatePickerDialog alloc] initWithCancelButton:NO];
Example initialization with locale:
LSLDatePickerDialog *dpDialog = [[LSLDatePickerDialog alloc] initWithLocale:[Locale localeWithLocaleIdentifier:@“ja_JP”]];
This code is distributed under the terms and conditions of the MIT license.