开发者

UISearchDisplayController gray overlay not fully covering table

开发者 https://www.devze.com 2023-03-17 08:00 出处:网络
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

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 goi开发者_C百科ng on? Thanks.

UISearchDisplayController gray overlay not fully covering table


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.


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!

0

精彩评论

暂无评论...
验证码 换一张
取 消