不需要的边距UIPopoverController [英] Unwanted margin UIPopoverController

查看:152
本文介绍了不需要的边距UIPopoverController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在视图中显示我的popover并将其放在视图的一侧时。总是有一个小的余量,导致popover不坚持到一边。

When I present my popover in a view and place it at the side of the view. There is always a small margin, causing the popover to not stick to the side.

UIViewController *vc =  [self getViewController:@"popover" fromStoryboard:@"Main"];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:vc];
[popover presentPopoverFromRect:CGRectMake(1100, 0, -65, 65)
                              inView:self.view
            permittedArrowDirections:UIPopoverArrowDirectionUp
                       animated:YES];
[vc setPreferredContentSize:CGSizeMake(300, 300)];

如何防止此边距并显示我的弹出窗口贴在视图的一侧?

How do I prevent this margin and show my popover sticking to the side of the view?

谢谢

推荐答案

我通过添加自己的UIPopoverBackgroundView实现修复了这个问题,我设置了自己的内容视图插图。

I fixed this issue by adding my own UIPopoverBackgroundView implementation where I set my own contentview insets.

+ (UIEdgeInsets)contentViewInsets {
    return UIEdgeInsetsMake(-10, -10, -10, -10);
}

并将此backgroundview添加到我的popovercontroller

and adding this backgroundview to my popovercontroller

[self.popover setPopoverBackgroundViewClass:[MyPopoverBackgroundView class]];

这篇关于不需要的边距UIPopoverController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆