ios - 如何将 FPPopover 移动到我想要的最低位置?如果我把它推得太低,它会跳回顶部

标签 ios objective-c uiview uipopovercontroller

我正在使用 FPPopover为我的 iPhone 应用程序显示弹出 View 。但是,我遇到了一个问题,当我展示它时,它只会让我展示它的位置太低,否则它会跳到顶部。而且这是在它被切断之前很久。

例如:

[self.speedOptionsPopover presentPopoverFromPoint:CGPointMake(0, 235)];

工作正常,但如果我将它设置为 255 而不是 235(因为它距离底部有 40 像素),它会跳回到顶部。

有没有人对此有任何经验或我该如何解决?

此外,如果您能解释为什么弹出窗口的内容总是从顶部开始 50 像素,而我希望它开始时更高,则加分。我怎样才能改变这个?

创建时的更多代码:

- (void)speedOptionsTapped:(UIBarButtonItem *)sender {
    // Set the delegate in the controller that acts as the popover's view to be self so that the controls on the popover can manipulate the WPM and number of words shown
    self.speedOptionsController.delegate = self;

    self.speedOptionsPopover.arrowDirection = FPPopoverNoArrow;
    self.speedOptionsPopover.border = NO;
    self.speedOptionsPopover.contentSize = CGSizeMake(320, 190);
    [self.speedOptionsPopover presentPopoverFromPoint:CGPointMake(0, 235)];
}

最佳答案

尝试替换 FPPopoverController.m 中的这部分代码:

//ok, will be vertical
if(ht == best_h || self.arrowDirection == FPPopoverArrowDirectionDown)

使用此代码:

//ok, will be vertical
if (self.arrowDirection == FPPopoverNoArrow)
{
   r.origin.x = p.x;
   r.origin.y = p.y;
}
else if(ht == best_h || self.arrowDirection == FPPopoverArrowDirectionDown)

您遇到此问题的原因可能是宏 FPPopoverArrowDirectionIsVertical 将没有箭头的弹出窗口视为具有垂直箭头。因此,结果是尝试将弹出窗口放置在尽可能靠近触发弹出窗口的 View 的最佳位置。

如果您按照上面的指示替换代码,您将为没有箭头的弹出框创建一个特殊情况,并要求在不重新定位的情况下尊重原始点。

关于ios - 如何将 FPPopover 移动到我想要的最低位置?如果我把它推得太低,它会跳回顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16513089/

相关文章:

ios - 将内容左对齐 - SwiftUI iOS 14 Widget

objective-c - 在桌面上显示进度栏(透明窗口) - Cocoa

iOS CGColor 与 UIColor

ios - 将值从 UIView 传递到 UIVIewController

ios - 防止 UIView 重叠

ios - 从 UIView 调用 UIView Controller

ios - 尝试将数据从 UIPicker 发送到 Firebase 数据库

ios - MTLCreateSystemDefaultDevice 在 iOS 13 模拟器上返回 nil

iphone - objective-c : for-loop gets slower and slower

iphone - 如何处理来自 UIImagePickerController 的多个图像?