I have searched and cannot find an answer to my problem.
I am using the following code to popup a UIDatePicker
when entering a UITextField
. It works perfectly on iPhone.
mySheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
[mySheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
CGRect pickerFrame = CGRectMake(0, 44, 0, 0);
UIDatePicker *datePicker = [[UIDatePicker alloc] initWithFrame:pickerFrame];
[datePicker setDatePickerMode:UIDatePickerModeTime];
if (whatPressed == 1) {
[datePicker setDate:startDate];
}
else
{
[datePicker setDate:endDate];
}
[mySheet addSubview:datePicker];
UIToolbar *controlToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, mySheet.bounds.size.width, 44)];
[controlToolBar setBarStyle:UIBarStyleBlack];
[controlToolBar sizeToFit];
UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *setButton = [[UIBarButtonItem alloc] initWithTitle:@"Set" style:UIBarButtonItemStyleDone target:self action:@selector(dismissDate)];
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(cancelDate)];
[controlToolBar setItems:[NSArray arrayWithObjects:spacer, cancelButton, setButton, nil] animated:NO];
[mySheet addSubview:controlToolBar];
[mySheet showInView:self.view];
[mySheet setBounds:CGRectMake(0, 0, 320, 485)];
I am now trying to use the same code for the iPad version and the view appears but it is not high enough. I have tried changing the CGRect
values but they don't seem to have any effect.
The view appears to be the width of an iPhone, and about 1cm in height. Confused.
Help appreciated.