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 textfield
- Feedback textview
which 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 UIKit
class 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.height
containerviewheight.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)
}
}