I am able to set date picker frame from Storyboard. But I am not able to set the frame programatically. I would like to no why datePicker.frame
is not working e
If you have already added UIDatePicker to .nib or .storyboard file and would like to update frame programatically, then you can update frame inside viewDidLayoutSubviews method in your view controller. I just tried to update frame and it worked on iOS 7.0
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
self.datePicker.frame = CGRectMake(0, 50, 300, 162);
}
If want to add a date picker programatically in view controller then you can try creating a date picker in viewDidLoad method and add it to subview.
UIDatePicker *datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 300, 300, 162)];
[self.view addSubview:datePicker];