iPad上的UIActionSheet中的UIDatePicker [英] UIDatePicker in UIActionSheet on iPad

查看:103
本文介绍了iPad上的UIActionSheet中的UIDatePicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序的iPhone版本中,我在 UIActionSheet 中有 UIDatePicker 。看来是对的。我现在正在设置应用程序的iPad版本,并且在iPad上查看时,相同的 UIActionSheet 显示为空白框。

In the iPhone version of my app, I have a UIDatePicker in a UIActionSheet. It appears correctly. I am now setting up the iPad version of the app, and the same UIActionSheet when viewed on the iPad appears as a blank blank box.

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

Here is the code I am using:

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:

I ended up creating a separate segment of code for the 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上的UIActionSheet中的UIDatePicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆