UIPopoverController presentPopoverFromRect无法正确显示

时间:2014-03-22 10:32:36

标签: ios objective-c uipopovercontroller

我正在加载显示摄像机视图的弹出窗口视图。一切都有效,但它不会比iPad上的扑克牌更大。无论我做什么,我都无法调整它只是改变它的位置。

这是我使用的代码

[self.popOver presentPopoverFromRect:CGRectMake(44, 6, 111, 111) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

如何调整大小?

更新

这就是我的整个方法:

- (void) cameraButtonSelected
{
    // create picker
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.allowsEditing = YES;
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    picker.preferredContentSize = CGSizeMake(400.0, 400.0);

    if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
        CGFloat scaleFactor=1.3f;
        picker.cameraViewTransform = CGAffineTransformScale(CGAffineTransformMakeRotation(M_PI * -90 / 180.0), scaleFactor, scaleFactor);
    }

    // create popover
    self.popOver = [[UIPopoverController alloc] initWithContentViewController:picker];
    [self.popOver presentPopoverFromRect:CGRectMake(44, 6, 111, 111) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}

3 个答案:

答案 0 :(得分:2)

尝试将此属性设置为popover

中包含的控制器
someViewController.contentSizeForViewInPopover = CGSizeMake(200.0, 200.0)

尝试使用

preferredContentSize

属性。

抱歉,我没有Mac来检查它

答案 1 :(得分:0)

您应该尝试在viewWillAppear中设置大小:

 - (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.popover.preferredContentSize = ...
  }

答案 2 :(得分:0)

没有什么对我有用,所以我在显示之后调整了popoverController的大小:

[popoverController presentPopoverFromRect:cell.mediaComment.frame
                                   inView:cell
                 permittedArrowDirections:UIPopoverArrowDirectionRight
                                 animated:YES];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    popoverController.contentViewController.preferredContentSize = REQUIRED_RECT.size;
    popoverView.frame = REQUIRED_RECT;
});