标签云

微信群

扫码加入我们

WeChat QR Code

I am new in iOS.My task is to send feedback data from feedback screen.In Feedback screen I have 3 fields:Name textfield Email textfieldFeedback textviewwhich were presented in a UIView.Based on the content in feedback textview, the height of textview should increase as well as when ever the textview height increasing or decreasing, the UIView height also vary.The main thing is, the textview should increase double of it's height and after that scroll action should perform.I am using Auto-layouts to achieve this.If any one can helps me to achieve this would be great.Thank in advance.Code ref:import UIKitclass FeedbackViewController: UIViewController {@IBOutlet weak var feedbacktextview: UITextView!@IBOutlet weak var textviewheight: NSLayoutConstraint!@IBOutlet weak var containerviewheight: NSLayoutConstraint!override func viewDidLoad() {super.viewDidLoad() self.navigationController?.setNavigationBarHidden(true, animated: false)}}extension FeedbackViewController: UITextViewDelegate{override func didChangeValue(forKey key: String) {textviewheight.constant = feedbacktextview.contentSize.heightcontainerviewheight.constant = feedbacktextview.frame.size.height//let fixedWidth = feedbacktextview.frame.size.width//let newSize = feedbacktextview.sizeThatFits(CGSize(width: fixedWidth, height: CGFloat.greatestFiniteMagnitude))//feedbacktextview.frame.size = CGSize(width: max(newSize.width, fixedWidth), height: newSize.height)}}


Possible duplicate of How do I size a UITextView to its content?

2019年04月25日22分07秒

My requirement is "textview height should increase upto double of it's initial heightbased on content as well as view should increase based on textview, if the content is crossed this textview height which is doubled, then scroll should come "

2019年04月25日22分07秒

Navya Then do this (textView.contentSize.height * 2). This will provide you double height.

2019年04月26日22分07秒

Navya Please remove the IF..ELSE condition from the adjustFrames() method.

2019年04月26日22分07秒