I'm trying to update a TextView dependent on the text that is inside it. I need to increase the height to the bottom direction when a user enters more text. than can fit on one line.
I'm currently using the following code:
-(void)textViewDidChange:(UITextView *)textView{
    CGRect newFrame = self.frame;
    newFrame.size.height = [self textViewHeightForAttributedText:
                       [[NSMutableAttributedString alloc] initWithString:self.text]
                       andWidth:self.frame.size.width];
    [self setNeedsLayout];
}
- (CGFloat)textViewHeightForAttributedText: (NSAttributedString*)text andWidth: 
(CGFloat)width {
    UITextView *calculationView = [[UITextView alloc] init];
    [calculationView setAttributedText:text];
    CGSize size = [calculationView sizeThatFits:CGSizeMake(width, FLT_MAX)];
    return size.height;
}
However, this isn't updating the height of the UITextView. I have set the delegate of the UITextView. This code is written in a subclass in a subclass of UITextView.
 
     
    