Iphone iPad上UIActionSheet中的UIDatePicker

Iphone iPad上UIActionSheet中的UIDatePicker,iphone,ipad,uidatepicker,uiactionsheet,Iphone,Ipad,Uidatepicker,Uiactionsheet,在我的应用程序的iPhone版本中,我在UIActionSheet中有一个UIDatePicker。它看起来是正确的。我现在正在设置该应用程序的iPad版本,在iPad上查看时,相同的UIActionSheet显示为一个空白框 以下是我正在使用的代码: UIDatePicker *datePickerView = [[UIDatePicker alloc] init]; datePickerView.datePickerMode = UIDatePickerModeDate;

在我的应用程序的iPhone版本中,我在
UIActionSheet
中有一个
UIDatePicker
。它看起来是正确的。我现在正在设置该应用程序的iPad版本,在iPad上查看时,相同的
UIActionSheet
显示为一个空白框

以下是我正在使用的代码:

UIDatePicker *datePickerView = [[UIDatePicker alloc] init];
    datePickerView.datePickerMode = UIDatePickerModeDate;

    self.dateActionSheet = [[UIActionSheet alloc] initWithTitle:@"Choose a Follow-up Date"
                                                   delegate:self cancelButtonTitle:nil 
                                     destructiveButtonTitle:nil otherButtonTitles:@"Done", nil];

    [self.dateActionSheet showInView:self.view];
    [self.dateActionSheet addSubview:datePickerView];
    [self.dateActionSheet sendSubviewToBack:datePickerView];
    [self.dateActionSheet setBounds:CGRectMake(0,0,320, 500)];

    CGRect pickerRect = datePickerView.bounds;
    pickerRect.origin.y = -95;
    datePickerView.bounds = pickerRect;

我最终为iPad Popover创建了一段单独的代码:

//build our custom popover view
UIViewController* popoverContent = [[UIViewController alloc] init];
UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 344)];
popoverView.backgroundColor = [UIColor whiteColor];

datePicker.frame = CGRectMake(0, 44, 320, 300);

[popoverView addSubview:toolbar];
[popoverView addSubview:datePicker];
popoverContent.view = popoverView;

//resize the popover view shown
//in the current view to the view's size
popoverContent.contentSizeForViewInPopover = CGSizeMake(320, 244);

//create a popover controller
UIPopoverController *popoverController = [[UIPopoverController alloc] initWithContentViewController:popoverContent];

//present the popover view non-modal with a
//refrence to the button pressed within the current view
[popoverController presentPopoverFromBarButtonItem:self.navigationItem.leftBarButtonItem 
                          permittedArrowDirections:UIPopoverArrowDirectionAny 
                                          animated:YES];

//release the popover content
[popoverView release];
[popoverContent release];

这个问题帮助我理解了苹果公司是如何期望用户在iPad上使用弹出窗口和操作表的,而不是他们的文档。谢谢。请检查我的答案,它可能会对您使用完整的。谢谢@Narayana,但这个问题是6年前提出来的:-)@Chris是的,我的问题也是6年前提出来的,我已经用swift更新了我的答案,所以添加了这个评论。检查这个答案这很好,但是我得到了预期日期选择器上方的空白白色框。有人知道我怎么用这个不动产吗?我想在这里设置一个标题。@AbuZubair您可能只需要在CGRect上设置一个负值,这样标签就会出现在未使用的空间中-hacky,但它可能会正常工作:-/