UIPopoverController too large and UIPickerView too small

前端 未结 1 1457
北恋
北恋 2021-01-21 07:46

I have a UIPickerView displayed inside a UIPopoverController. The dimensions of the UIPickerView are: 320x216. For some rea

相关标签:
1条回答
  • 2021-01-21 07:52

    The reason for the "squashed" picker view seems to be this line:

    [pickerController setView:self.picker];
    

    Instead, add the picker view as a subview:

    [pickerController.view addSubview:picker];
    


    Next, to fix the popover height, set popoverContentSize before presenting it:

    pickerPopover.popoverContentSize = picker.frame.size;
    


    Also, fix the picker view's frame from this:

    CGRectMake(0, self.view.bounds.size.height+44, 320, 216)
    

    to this:

    CGRectMake(0, 0, 320, 216)
    
    0 讨论(0)
提交回复
热议问题