0

我在其中呈现带有 UITextField 的弹出框。一切正常(箭头指向 sourceRect)。然后我点击文本字段并打开键盘。弹出框被移动并且箭头方向被改变。那也很好。但是当我关闭键盘时,箭头保持在同一方向。

这是我的简单项目https://github.com/sirljan/PopoverArrow

我是这样介绍的:

- (IBAction)buttonTapped:(UIButton *)sender {
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UIViewController * vc = [sb instantiateViewControllerWithIdentifier:@"MyPopover"];
    vc.modalPresentationStyle = UIModalPresentationPopover;
    vc.popoverPresentationController.sourceView = self.view; \\self.view is sender.superview
    vc.popoverPresentationController.sourceRect = sender.frame;
    vc.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionDown | UIPopoverArrowDirectionUp;
    [self presentViewController:vc animated:YES completion:nil];
}

我只想让箭头向上或向下。是只读的,所以在被调用popoverPresentationController.arrowDirection时我无法更改它。 - popoverPresentationController:willRepositionPopoverToRect:inView:您对如何正确设置箭头有什么建议吗?

在此处输入图像描述

4

0 回答 0