2

Im trying to accomplish a comment UITextView similar to Instagrams. I previously did this with UITableView and used beginUpdates and endUpdates to reload the footer size as the user enter their comments. With my collectionView I've tried a few different ways to reload my footer but the view scrolls up to its original position, hiding the textView under the keyboard. Im trying to keep the UITextView above the keyboard and have it expand for each new line.

- (void)textViewDidChange:(UITextView *)textView{
        NSInteger numLines;
        numLines = textView.contentSize.height/textView.font.lineHeight;
        if (numLines > nextLine) {
            height = height + 15;
            [self.collectionView.collectionViewLayout invalidateLayout];
            [footer.commentTextView becomeFirstResponder];
            CGPoint scrollPt = CGPointMake(0, 300);
            [self.collectionView setContentOffset:scrollPt animated:NO];

            nextLine = numLines;
   }
}

 - (CGSize) collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section{
    return CGSizeMake(320, height);
}
Juan Catalan
  • 2,299
  • 1
  • 17
  • 23
Peter
  • 1,053
  • 13
  • 29

0 Answers0