UIPopover没有出现在正确的位置

时间:2013-09-16 11:45:31

标签: objective-c ipad uipopovercontroller

使用此代码; iPad UIPopover出现在屏幕的顶部,而不是按下它的按钮上方 - 我知道苹果拒绝了应用程序,所以有没有办法使它显示在按下的按钮上方? 这是当前调用它的代码;

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
       self.popover = [[UIPopoverController alloc] initWithContentViewController:(UIViewController *)picker];
        CGRect takePhotoRect;
        takePhotoRect.origin = self.view.frame.origin;
        takePhotoRect.size.width = 1;
        takePhotoRect.size.height = 1;
        [self.popover setPopoverContentSize:CGSizeMake(320.0, 216.0)];

        [self.popover presentPopoverFromRect:takePhotoRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

1 个答案:

答案 0 :(得分:0)

在你的

[self.popover presentPopoverFromRect:takePhotoRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

方法,使用按钮的框架,如:

[self.popover presentPopoverFromRect:myButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];