TagListView icon indicating copy to clipboard operation
TagListView copied to clipboard

TagListView number of rows(not tagViews)

Open sergstav opened this issue 5 years ago • 13 comments

Hello to all, how can I get the number of rows(not tagViews) in the TagListView? I need height of taglistview, but can't get correct value.

sergstav avatar Aug 21 '18 20:08 sergstav

You can get the height of taglistview from tagListView.intrinsicContentSize.height.

Hira-shrestha avatar Aug 27 '18 05:08 Hira-shrestha

@Hira-shrestha intrinsicContentSize.height return's wrong height for me, for example if i have 8 tags and 21 taglistview height, and some margins, then I get 196

sergstav avatar Aug 27 '18 07:08 sergstav

@sergstav

intrinsicContentSize.height return's wrong height for me, for example if i have 8 tags and 21 taglistview height, and some margins, then I get 196

what's the expected value?

anti-transmission avatar Aug 31 '18 11:08 anti-transmission

@anti-transmission When I first load tableview with tags, I have 8 tags in cell and 21 taglistview height, displays as two rows, but intrinsicContentSize.height returns (8*21) + margins = 196. But expected value I think should be 2(rows) * 21. I see that rows property used for count of tags, not actually rows. But, after reload I get correct values, so my question maybe is how to get correct value when I load table, I tried invalidateIntrinsicContentSize() but without success.

sergstav avatar Aug 31 '18 11:08 sergstav

it will be easier to debug if you attach a project.

anti-transmission avatar Aug 31 '18 12:08 anti-transmission

 if appeal.labels.count > 0 {
            lastMessageLabel.snp.removeConstraints()
            lastMessageLabel.snp.makeConstraints { (make) in
                make.top.equalTo(subjectLabel.snp.bottom).offset(3)
                make.left.equalToSuperview().offset(43)
                make.bottom.equalTo(tagListView.snp.top).offset(-7)
            }
            tagListView.snp.removeConstraints()
            tagListView.snp.makeConstraints { (make) in
                make.height.equalTo(tagListView.intrinsicContentSize.height)
                make.left.equalToSuperview().offset(44)
                make.right.equalToSuperview().offset(-16)
                make.bottom.equalToSuperview().offset(-17)
            }
            tagListView.isHidden = false
        }

I get the error only when cell loads first, after reload all works as expected.

sergstav avatar Aug 31 '18 12:08 sergstav


Sent with GitHawk

sergstav avatar Aug 31 '18 20:08 sergstav

@anti-transmission some news?

sergstav avatar Sep 04 '18 14:09 sergstav

same here, cant get the correct height of tagListView, rows property is actually getting the tags and not the rows.

barcennas avatar Oct 12 '18 04:10 barcennas

So who can tell me how to solve it please ....

zyflovelam avatar Nov 23 '18 02:11 zyflovelam

Hi All, How can i restrict two tags in a row ?

Akash1604 avatar Nov 30 '18 11:11 Akash1604

override open var intrinsicContentSize: CGSize {
        var height = CGFloat(rows) * (tagViewHeight + marginY)
        if rows > 0 {
            height -= marginY
        }
        return CGSize(width: frame.width, height: height)
    }

and

    private func rearrangeViews() {
   ...
      for (index, tagView) in tagViews.enumerated() {
            tagView.frame.size = tagView.intrinsicContentSize
            tagViewHeight = tagView.frame.height
  ...
}

i think if tagViewHeight is diffrent in rowViews. the result is incorrect

kkkelicheng avatar Dec 10 '18 07:12 kkkelicheng

Try tagListView.subviews.count I do not know why this works but, at least in my testing it seems to be equal to the number of rows.

fellowProgrammer avatar Jan 06 '19 18:01 fellowProgrammer