操作表中的Uipickerview显示在iPhone中,但不显示在iPad中

时间:2014-06-10 11:07:07

标签: ios iphone ipad uipickerview uiactionsheet

首先,这是iPhone和iPad中的图片

iPhone:http://img4.hostingpics.net/pics/563577Capturedcran20140610125811.png iPad:http://img4.hostingpics.net/pics/315654Capturedcran20140610125901.png

我正在做的事情:

_questionnairePicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0,44.0, 320.0, 250.0)];
_questionnaireActionSheet = [[UIActionSheet alloc] initWithTitle:@"Questionnaire"
                                                        delegate:self
                                               cancelButtonTitle:nil
                                          destructiveButtonTitle:nil
                                               otherButtonTitles:nil];


_questionnaireActionSheet.backgroundColor = [UIColor whiteColor];
_dateActionSheet.backgroundColor = [UIColor whiteColor];
self.selectedIndexQuestionnaire = 0;
self.questionnairePicker.delegate = self;
[self.questionnaireActionSheet addSubview:[self getToolBarActionSheet:self.questionnairePicker]];
[self.questionnaireActionSheet addSubview:self.questionnairePicker];

 -(UIToolbar *)getToolBarActionSheet:(UIView *)aPicker
    {

    UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
    [pickerToolbar sizeToFit];
    NSMutableArray *barItems = [[NSMutableArray alloc] init];

    UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc]
                                initWithBarButtonSystemItem:UIBarButtonSystemItemDone
                                target:self action:@selector(pickerDoneClick:)];

    UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc]
                                  initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
                                  target:self action:@selector(pickerCancelClick:)];

    UIBarButtonItem *flex = [[UIBarButtonItem alloc]
                             initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
                             target:self action:nil];


    if(aPicker.tag == 2) doneBtn.tag = cancelBtn.tag = 2;


    [barItems addObject:cancelBtn];
    [barItems addObject:flex];
    [barItems addObject:doneBtn];


    [pickerToolbar setItems:barItems animated:YES];

    return pickerToolbar;
}   

那么,有人知道解决问题的好方法吗?

1 个答案:

答案 0 :(得分:0)

ipad上的UIPickerViews没有默认大小(即宽度)。

变化

_questionnairePicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0,44.0, 320.0, 250.0)];

_questionnairePicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 345, 400, 216)];