maltsugar / CustomPopoverView

一款小巧灵活的自定义弹出视图, 可以做自定义AlertView、弹出窗口等等, A tiny and sweet custom popView (pop popup)
MIT License
193 stars 34 forks source link

view大小和屏幕同宽就出问题了 #7

Closed czl0325 closed 4 years ago

czl0325 commented 6 years ago

当你把弹出的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]; }

//或者

maltsugar commented 6 years ago

感谢反馈,这种宽度和屏幕一样时,需要定义config 四周的间隙为0。不然默认会有间隙。 我的代码问题是如果只设置config某些值,未设置行高,会导致tableView 行高为0。 现在已修改,再次感谢

czl0325 commented 6 years ago

还是不行,我在你demo上的- (void)optionClick:(UIButton *)sender函数写的,你看看

}

czl0325 commented 6 years ago

设置成与屏幕同宽,然后把sender传进去,不能传nil

czl0325 commented 6 years ago

你看看PopOverVieConfiguration的配置对吗?

maltsugar commented 6 years ago

现在可以了 你可以试下。 宽度和屏幕一样时,只是建议把PopOverVieConfiguration 设置下四周间隙为0,不然肯定会超出一点。如果sender不传就是居中显示,居中显示时建议 小三角宽高设置为0

maltsugar commented 6 years ago

你重新下载啊 直接可以跑

czl0325 commented 6 years ago

1

奇怪,你不会出现这种情况吗?

maltsugar commented 6 years ago

这种情况宽度也不能是屏幕宽度,因为弹出视图和按钮右对齐。你视图宽度,最大为屏幕宽度-按钮离屏幕右边的空隙- 2*四周间隙。 如果你用这个按钮左对齐,那么留给视图宽度将会更窄,需要自己衡量的

czl0325 commented 6 years ago

还有一个问题,你是加在windows上的,如果点击你view里面的cell触发一个弹框事件,会导致你的CustomPopOverView被销毁,如何让他还是存在呢?

maltsugar commented 6 years ago

声明成全局的,让VC强引用