简体   繁体   English

UITableView嵌套在UICollectionViewCell中,没有边距

[英]UITableView Nested in UICollectionViewCell with No Margins

In my current project I am using a UITableView nested inside each UICollectionViewCell. 在我当前的项目中,我正在使用嵌套在每个UICollectionViewCell内的UITableView。 Within the UITableView I have a number of custom UITableViewCells separated by borders as seen in the screenshot. 在UITableView中,我有许多自定义UITableViewCells,它们由边框分开,如屏幕截图所示。

I am wanting each border tp stretch the entire length of the screen from left to right, but as you can see in the first image each border stops short of the outer edge of the screen. 我希望每个边框tp从左到右延伸整个屏幕长度,但是正如您在第一张图片中所看到的那样,每个边框都在屏幕外边缘附近停止。

In the second screenshot I have put a border around the entire edge of the UITableView to confirm that it is indeed the sizing of the UITableView that is causing this issue. 在第二张屏幕截图中,我在UITableView的整个边缘周围放置了一个边框,以确认确实导致此问题的是UITableView的大小。

In the Storyboard the top, bottom, left and right constraints of the UITableView are set to be the same as UICollectionViewCell. 在情节提要中,将UITableView的顶部,底部,左侧和右侧约束设置为与UICollectionViewCell相同。

In the UICollectionViewCell's properties I have set fixed margins all to be 0, and "Safe Area Relative Margins" has been deselected. 在UICollectionViewCell的属性中,我将固定边距全部设置为0,并且已取消选择“安全区域相对边距”。

Also when initializing the UICollectionViewCell I have tried: 另外,在初始化UICollectionViewCell时,我尝试过:

self.layoutMargins = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)

Thanks for any help you can give. 谢谢你提供的所有帮助。

First Screenshot 第一个截图

Second Screenshot 第二个截图

I'm an idiot... Forgot that contentViews were a thing. 我是个白痴...忘了contentViews是一回事。

Used: self.contentView.layoutMargins = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) and everything was peachy. 使用: self.contentView.layoutMargins = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) ,一切都变得柔和。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM