UIPopoverController中的UIImagePickerController - 位置不起作用

时间:2014-02-08 21:59:02

标签: uiimagepickercontroller uipopovercontroller

在我正在编写的iPad应用程序中,我在静态表格单元格中有一个按钮,可以在弹出窗口中启动图像选择器。

我希望popover的箭头指向启动弹出窗口的按钮。现在,当我点击按钮时,它没有。它会在屏幕上抛出弹出窗口(带有工作图像选择器),但箭头指向屏幕顶部或其他任何地方(无法弄清楚它是否随机 - 见下文)。

保存包含按钮的静态单元格的tableview已禁用其滚动但位于滚动视图上。这会导致随机箭头位置吗?

这是我的代码:

// present image picker in a popover
_imagePicker = [[UIImagePickerController alloc] init];
_imagePicker.delegate = self;
_imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
_imagePicker.allowsEditing = NO;
_imagePicker.navigationBar.tintColor = [UIColor redColor];
_imagePicker.navigationBar.backgroundColor = [UIColor greenColor];
_popover = [[UIPopoverController alloc] initWithContentViewController:_imagePicker];
[_popover presentPopoverFromRect:self.theButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

有人可以解释为什么箭头没有指向按钮的框架和/或如何解决它?

感谢。

1 个答案:

答案 0 :(得分:1)

该按钮可能不是self.view的直接子视图。

尝试:

[_popover presentPopoverFromRect:self.theButton.frame inView:self.theButton.superview permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
相关问题