iOS-Tips | iOS knowledge collection
kandi X-RAY | iOS-Tips Summary
kandi X-RAY | iOS-Tips Summary
iOS knowledge collection
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of iOS-Tips
iOS-Tips Key Features
iOS-Tips Examples and Code Snippets
Community Discussions
Trending Discussions on iOS-Tips
QUESTION
I am having a horrible time trying to fix the width of a textview in autolayout. The textview is the dominant element in the screen so my inability to fix it is wrecking the entire screen.
The set up is a view containing a scrollview, containing a content view containing elements. Following Apple's instructions, I set the width of the view, scrollview and content view to 375 and pinned the contentview to the scrollview and scrollview to the view on all four sides, all with constants of 0.
I would like the textview to be centered and fairly wide. Accordingly, I first set it with a leading constant to contentview of 40, a trailing constant to contentview of 40, and a width of 295. On a 7 Plus, this left too wide a margin at the right and on a SE, the textview extended beyond the right margin. The natural thing seemed to be to remove the width constraint so there was only a leading and trailing constraint but this caused the entire view to shrink town to 113. There is no discernible reason I can come up with for this to happen, but happen it did. I then tried resetting to 295 but less than or equal. I also tried setting to 295 but lowering the priority. At priority 750, it acted as though at 1000. At priority 500, the view shrank back down to 113.
Most exasperating. Attached see screenshots of the constraints. Thanks in advance for any suggestions.
Edit:
It appears from this post that UITextViews may not adjust their size in response to autolayout. So perhaps there is no way to do this all in autolayout instoryboard with wiring a constraint and modifying it with code. I can't believe that Apple does not support autolayout with textviews in story board so still hoping there is a better way.
...ANSWER
Answered 2017-Dec-31 at 17:00Control drag from the content view to the outmost view and make them Equal Widths
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install iOS-Tips
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page