UISearchDisplayController 灰色覆盖未完全覆盖表格

发布于 2024-11-18 18:55:17 字数 197 浏览 6 评论 0原文

我遇到一个问题,当显示键盘时,自动覆盖在 UISearchDisplayController 上的灰色覆盖层并不总是完全覆盖表格区域(您可以在下图中看到底部的白色)。这种情况并不总是发生,但它的频率足够高,以至于令人烦恼。有人知道发生了什么事吗?谢谢。

覆盖问题

I'm having an issue where the gray overlay that's automatically put over my UISearchDisplayController when the keyboard is shown doesn't always fully cover the table area (you can see the white on the bottom in the picture below). This doesn't always happen but it's frequent enough that it's annoying. Anyone know what's going on? Thanks.

overlay issue

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

国际总奸 2024-11-25 18:55:17

我相信这是苹果代码中的一个错误。在广泛使用 UIPopoverControllers 后,我发现在很多情况下,弹出窗口在执行大小计算时会混淆它是否有导航栏。

我相信,如果您测量白框的高度,您会发现它恰好是 37 像素:弹出窗口中导航栏的高度。 (弹出窗口中的导航栏不像大多数导航控制器那样高 44 像素,因为它们嵌入到弹出窗口的边框中。)

如果您能够访问灰色覆盖层并手动调整其大小,您可以考虑导航栏的高度或缺少导航栏的高度。不幸的是,由于覆盖层是由搜索栏控制的,因此您有点陷入困境。

我的建议是尝试让弹出窗口在出现或调整大小后重新计算其内容的大小。当动态调整包含导航栏的 UIPopover 的大小时,我会使用这种模式:

// UIViewController subclass with a navigation bar which is displayed in a popover
// _popoverController is a (unretained) pointer to the UIPopoverController in which this view controller is displayed

- (void)viewDidLoad 
{
    [self.view sizeToFit];

    CGSize newSize; // Dynamically computed based on popover contents
    self.contentSizeForViewInPopover = newSize;
    newSize.height += 37; // Account for popover navigation bar
    [_popoverController setPopoverContentSize:size animated:YES];
}

我不知道这个答案会有多大帮助,但我希望它至少会给您带来正确方向的推动。

I believe this is a bug in Apple's code. Having worked extensively with UIPopoverControllers, I have found that there are many occasions in which a popover becomes confused as to whether or not it has a navigation bar when performing sizing calculations.

I am confident that if you measure the height of the white box you will find that it is exactly 37 pixels: the height of a navigation bar in a popover. (Navigation bars in popovers are not 44 pixels high like most navigation controllers since they are embedded into the popover's border.)

If you were able to access the gray overlay and manually resize it you could account for the height of the navigation bar or lack thereof. Unfortunately you are in a bit of a bind since the overlay is controlled by the search bar.

My suggestion would be to try to get the popover to recompute the size of its contents after it appears or is resized. I use this pattern when dynamically resizing a UIPopover containing a navigation bar when it appears:

// UIViewController subclass with a navigation bar which is displayed in a popover
// _popoverController is a (unretained) pointer to the UIPopoverController in which this view controller is displayed

- (void)viewDidLoad 
{
    [self.view sizeToFit];

    CGSize newSize; // Dynamically computed based on popover contents
    self.contentSizeForViewInPopover = newSize;
    newSize.height += 37; // Account for popover navigation bar
    [_popoverController setPopoverContentSize:size animated:YES];
}

I don't know how much this answer will help, but I hope it will at least give you a push in the right direction.

薄荷梦 2024-11-25 18:55:17

看看这篇文章:http://www.cannonade.net/blog.php? id=1498

他讨论了这个问题,提供了一个(他自己称为)丑陋的解决方法,但也说明了如何解决它!

Have a look in this post: http://www.cannonade.net/blog.php?id=1498

He discusses the problem, providing a (called by himself) ugly workaround, but also says how to fix it!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文