Post not yet marked as solved
Click to stop watching this thread.
You have stopped watching this post. Click to start watching again.
Post marked as unsolved with 1 replies, 0 views
Replied In
DatePicker Objective-C mirrors day numbers
UITextField * displayTextField = [[UITextField alloc] initWithFrame:CGRectMake(0, 250, [[self view] frame].size.width - 10, 30)];
displayTextField.backgroundColor = [UIColor redColor];
displayTextField.text = @"DatePicker";
displayTextField.textAlignment = NSTextAlignmentCenter;
UIDatePicker * datePicker1 = [[UIDatePicker alloc] init];
datePicker1.datePickerMode = UIDatePickerModeDate;
datePicker1.preferredDatePickerStyle = UIDatePickerStyleInline;
datePicker1.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;
datePicker1.frame = CGRectMake(datePicker1.frame.origin.x, datePicker1.frame.origin.y, datePicker1.frame.size.width, 360);
[datePicker1 addTarget:self action:@selector(startDateSelected:) forControlEvents:UIControlEventValueChanged];
CGFloat width = [[UIScreen mainScreen]bounds].size.width;
UIToolbar * toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, width, 44)];
toolbar.barStyle = UIBarStyleDefault;
toolbar.translucent = YES;
[toolbar layoutIfNeeded];
UIBarButtonItem * spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace menu:nil];
UIBarButtonItem * doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self
action:@selector(dismiss)];
toolbar.items = @[spacer, doneButton];
displayTextField.inputView = datePicker1;
displayTextField.inputAccessoryView = toolbar;
[[self view] addSubview:displayTextField];