set the width of a UIText view based on the content size property
        Posted  
        
            by 
                Mrwolfy
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Mrwolfy
        
        
        
        Published on 2012-09-12T03:30:31Z
        Indexed on 
            2012/09/12
            3:38 UTC
        
        
        Read the original article
        Hit count: 199
        
TextView.contentSize.width does not work to set the UITextView's .frame.size.width.
[TextView setFrame:CGRectMake(TextView.frame.origin.x, TextView.frame.origin.y, TextView.contentSize.width, TextView.contentSize.height)];  
Setting the UITextView's frame height to the contentSize.height property works to make the view's frame scale to the proper size for the current vertical size of the content. For some reason, the width of the view's frame does not respond in the same way. It just remains the same size regardless of the amount of text input.
When I log the contentsize of the UITextView dynamically, as I am typing in text to the view, the height property chnges, while the width does not. Makes me wonder what the width property is doing, what's it for.
© Stack Overflow or respective owner