UITableview显示一项而不是两项 [英] UITableview showing one item instead of two items swift xcode

查看:54
本文介绍了UITableview显示一项而不是两项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在UITableviewCell内使用UIStackview时发现了问题.

I found the issue while using the UIStackview inside the UITableviewCell.

在UIStackView中,我添加了四个stackview,将在以下图像中进行解释.

Here inside the UIStackView i have added four stackview which will explain in Following images.

我设计为UITableViewCell的设计

The design which i have designed as UITableViewCell

和UTableviewCells中使用的视图在下面给出

and the views used in UTableviewCells are given below

那我就分享了这种观点的全部矛盾之处

then i share the complete contraints of this view

此特定内容的结果在iphone 8中可以正常工作,而在模拟器中的iphone 11 Pro max上则无法工作.就像下面的图片一样显示

result of this particular constaints is working fine in iphone 8 whereas it is not working on iphone 11 Pro max in simulator. it is showing like below image

,它在UITableview中仅显示一项.数组中实际上有两个项目.

and it is showing only one item in UITableview. actually there are two items in the array.

,当我滚动表格视图时,我可以找到第二个项目.如下所示的第二项

and i can find the second item when i scroll the tableview. second item shown below

过去三天,我一直被这个问题困扰.任何人都可以给出解决方案,或者在我犯错的地方.

i am stuck with this problem past three days.Any body can give the solution or where i made mistake.

我想要的是,视图应拉伸至全角,UITableview应显示两个项目.

what i want is,the view should be streched to full width and UITableview should show two items.

我们将不胜感激.

添加以下代码后.

  NSLayoutConstraint.activate([
             rootStackView.leadingAnchor.constraint(equalTo: leadingAnchor),
             rootStackView.trailingAnchor.constraint(equalTo: trailingAnchor),
             rootStackView.topAnchor.constraint(equalTo: topAnchor),
             rootStackView.bottomAnchor.constraint(equalTo: bottomAnchor),
  ])

和UITableview这样显示.

and the UITableview showing like this.

我已经在UITableViewCell类中添加了以上代码.

i have added the above code in UITableViewCell class.

编辑

这是对UITableView的约束

this is constraint for UITableView

Data Table.leading = Safe Area.leading
Data Table.trailing = safe Area.trailing
Data Table.top = Header.bottom+70
Reply view.top = Data Table.bottom

UITabbleView显示带有基本标签的两个项目.该标签有说明.

UITabbleView showing two items with basic label. this label has description.

推荐答案

问题可能出在您的表格视图约束上.尾随底线.

The problem could be your table view’s constraint. Trailing and bottom.

这篇关于UITableview显示一项而不是两项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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