I implemented the UIDatePicker
in iPhone and it's working correctly.
The same code I tried with iPad but it is not showing me UIDatePicker
.
I read somewhere that I need to show it with UIPopOverController
and find this
link but it is not showing the proper code.
I can't make a separate XIB for that. I have to implement it by code itself. Mine is IOS5.
I use the following code:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
if (textField.tag == 1)
{
[self showDatePickerIniPad];
}
}
-(void)showDatePickerIniPad
{
UIViewController *popoverContent = [[UIViewController alloc] init];
UIView *popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
popoverView.backgroundColor = [UIColor whiteColor];
datePicker.frame = CGRectMake(0, 0, 320, 300);
[popoverView addSubview:datePicker];
popoverContent.view = popoverView;
popoverContent.contentSizeForViewInPopover = CGSizeMake(320, 244);
UIPopoverController *popoverController = [[UIPopoverController alloc] initWithContentViewController:popoverContent];
[popoverController presentPopoverFromRect:CGRectZero inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
txt_FromDate.inputView = datePicker;
}