строку.Q:
How can i make the date picker working with the button instead of the keyboard?
This is my date picker working with keyboard
I want to make it working with a button.
this is my code :
ViewController.h
@property (weak, nonatomic) IBOutlet UIPickerView *PickerView;
@property (weak, nonatomic) IBOutlet UIDatePicker *DatePicker;
ViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self PickerView];
[self DatePicker];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// Do any additional setup after loading the view, typically from a nib.
- (IBAction)selectDate:(id)sender {
if ([self.DatePicker isHidden]) {
[self.DatePicker setHidden:NO];
}
else {
[self.DatePicker setHidden:YES];
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
if (component == 0) {
NSDate *date = [NSDate date];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd-MM-yyyy"];
self.DatePicker.date = date;
if (component == 1) {
[dateFormat setDate
Related links:
Comments