首先,这是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;
}
那么,有人知道解决问题的好方法吗?
答案 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)];