【问题标题】:Pickerview in Actionsheet displaying in iPhone but not in iPad操作表中的 Pickerview 在 iPhone 中显示,但在 iPad 中不显示
【发布时间】:2014-06-10 11:07:06
【问题描述】:

首先,这是 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;
}   

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

【问题讨论】:

  • 你找到答案了吗?我有同样的问题

标签: ios iphone ipad uipickerview uiactionsheet


【解决方案1】:

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

改变

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

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

【讨论】:

  • 同样的问题..问题不是宽度而是高度
  • _questionnairePicker.deleget=self;
猜你喜欢
  • 2017-07-07
  • 1970-01-01
  • 2019-12-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-21
  • 1970-01-01
相关资源
最近更新 更多