以编程方式将内容的摘要高度设置为uiview高度,并将其添加到容器并调整其大小

时间:2022-08-23 23:45:08

There is product page. Here is many data - about it: photo, price, portion selector, button to add product in cart and many more. In the bottom (according to design layots) I must place view with tabs - (about and comments). "About" - contains product name, product description, few other items, "comments" contains UITableView with product comments and field for entering comment.

有产品页面。这里有很多数据 - 关于它:照片,价格,部分选择器,在购物车中添加产品的按钮等等。在底部(根据设计草案)我必须用标签放置视图 - (关于和评论)。 “关于” - 包含产品名称,产品描述,其他一些项目,“评论”包含带有产品评论的UITableView和用于输入评论的字段。

All these guys are not housing in standart screen - it is reason to use uiscrollview. I place all my views inside contentView of scroll view, add constraints and I get some free space at bottom of scrollview. I place here uiview - and add costraint bottom to bottom of superview and top to bottom of tabs (custom, because i need use design layouts), the lower view in scroll view. Consequently I get view which has no strong height constraints - I want use it as an container to place "about" and "comments" views depending on tab pressed. Height of about and comments is different for different products, therefore i must calculate height of about or comments page (depends on contains information) - at first, at second resize container for it. Is there way to do this?

所有这些人都没有在标准屏幕上住 - 这是使用uiscrollview的原因。我将所有视图放在scrollView的contentView中,添加约束,并在scrollview底部获得一些空闲空间。我在这里放置uiview - 并在superview的底部和标签的顶部到底部添加costraint(自定义,因为我需要使用设计布局),滚动视图中的下部视图。因此,我获得了没有强烈高度限制的视图 - 我希望将其用作容器,根据按下的选项卡放置“about”和“comments”视图。对于不同的产品,约和高度的评论是不同的,因此我必须计算约的高度或评论页面(取决于包含信息) - 首先,在第二个调整大小容器。有办法做到这一点吗?

I attach two images - design layout and my stroryboard screenschot where I add red selection of contatiner which I want to contains "about" or "comments".

我附上了两个图像 - 设计版面和我的stroryboard screenchot,我添加了红色选择的contatiner,我想包含“about”或“comments”。

以编程方式将内容的摘要高度设置为uiview高度,并将其添加到容器并调整其大小 以编程方式将内容的摘要高度设置为uiview高度,并将其添加到容器并调整其大小

1 个解决方案

#1


0  

Yes, a great decision! )) I will use not a container and .xib created view, I will use UITableView in both cases - comments and product. And will set scrollingDisabled = true parameter to it. In that case tableview must resize by height and all be good, all what I need - create tableview datasourse and delegate to both cases. I will try it tomorrow, and tell you about results )

是的,一个伟大的决定! ))我将不使用容器和.xib创建的视图,我将在两种情况下使用UITableView - 注释和产品。并将scrolllingDisabled = true参数设置为它。在这种情况下,tableview必须按高度调整大小并且一切都很好,所有我需要的 - 创建tableview数据并委托给两个案例。我会在明天试一下,然后告诉你结果)

#1


0  

Yes, a great decision! )) I will use not a container and .xib created view, I will use UITableView in both cases - comments and product. And will set scrollingDisabled = true parameter to it. In that case tableview must resize by height and all be good, all what I need - create tableview datasourse and delegate to both cases. I will try it tomorrow, and tell you about results )

是的,一个伟大的决定! ))我将不使用容器和.xib创建的视图,我将在两种情况下使用UITableView - 注释和产品。并将scrolllingDisabled = true参数设置为它。在这种情况下,tableview必须按高度调整大小并且一切都很好,所有我需要的 - 创建tableview数据并委托给两个案例。我会在明天试一下,然后告诉你结果)