0

I have an ViewController that has a title, an image and long text. I want it to be scrolled as a whole not the only text.

I am calculating the size according to its text. It is calculated correct but, I tried with that code.

newsDetailTextView.heightAnchor.constraint(equalToConstant:newsDetailString.height(containerWidth: newsDetailTextView.frame.size.width)).isActive = true

Its size does not change.

What might be the wrong?

Could you please indicate me the way?

BR,

Erdem

erdemgc
  • 1,701
  • 3
  • 23
  • 43
  • `UILabel` and `UITextView` are different entities. One is for display, another is for input. In what scenario do you use them interchangeably? – Rakesha Shastri Aug 06 '18 at 16:38
  • 3
    Possible duplicate of [Figure out size of UILabel based on String in Swift](https://stackoverflow.com/questions/30450434/figure-out-size-of-uilabel-based-on-string-in-swift) – Rakesha Shastri Aug 06 '18 at 16:39
  • Do you need the "long text" to be editable? – DonMag Aug 06 '18 at 18:31

2 Answers2

0

Set scrollEnabled property of textView to false or uncheck via storyboard.

shivi_shub
  • 1,018
  • 1
  • 7
  • 15
-1

I recommend you to read here if you want use a constraints way.

Check the Apple's official documentation in Listing 13-1 where used heightAnchor.

Agisight
  • 1,778
  • 1
  • 14
  • 15