Closed czl0325 closed 4 years ago
感谢反馈,这种宽度和屏幕一样时,需要定义config 四周的间隙为0。不然默认会有间隙。 我的代码问题是如果只设置config某些值,未设置行高,会导致tableView 行高为0。 现在已修改,再次感谢
还是不行,我在你demo上的- (void)optionClick:(UIButton *)sender函数写的,你看看
(void)optionClick:(UIButton *)sender {
NSArray menus = @[@"清空已完成", @"清空全部"]; // CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 300) PopOverVieConfiguration config = [PopOverVieConfiguration new]; config.triAngelHeight = 8.0; config.triAngelWidth = 10.0; config.containerViewCornerRadius = 10.0; config.roundMargin = 0; config.showSpace = 0;
CustomPopOverView *pView = [[CustomPopOverView alloc]initWithBounds:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 300) titleMenus:menus config:config]; pView.delegate = self; pView.containerBackgroudColor = RGBCOLOR(64, 64, 64); [pView showFrom:sender alignStyle:CPAlignStyleRight];//这个黑体部分,注意你要传入sender
}
设置成与屏幕同宽,然后把sender传进去,不能传nil
你看看PopOverVieConfiguration的配置对吗?
现在可以了 你可以试下。 宽度和屏幕一样时,只是建议把PopOverVieConfiguration 设置下四周间隙为0,不然肯定会超出一点。如果sender不传就是居中显示,居中显示时建议 小三角宽高设置为0
你重新下载啊 直接可以跑
奇怪,你不会出现这种情况吗?
这种情况宽度也不能是屏幕宽度,因为弹出视图和按钮右对齐。你视图宽度,最大为屏幕宽度-按钮离屏幕右边的空隙- 2*四周间隙。 如果你用这个按钮左对齐,那么留给视图宽度将会更窄,需要自己衡量的
还有一个问题,你是加在windows上的,如果点击你view里面的cell触发一个弹框事件,会导致你的CustomPopOverView被销毁,如何让他还是存在呢?
声明成全局的,让VC强引用
当你把弹出的popupview宽度设置成和屏幕一样宽,就出问题了。例如改你demo的源码如下:
注意黑色粗体部分: `- (void)optionClick:(UIButton )sender { NSArray menus = @[@"清空已完成", @"清空全部"]; CustomPopOverView *pView = [[CustomPopOverView alloc]initWithBounds:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 300) titleMenus:menus config:nil]; pView.delegate = self; pView.containerBackgroudColor = RGBCOLOR(64, 64, 64); [pView showFrom:sender alignStyle:CPAlignStyleRight]; }
//或者