UITextView
Instagramと同様のコメントを達成しようとしています。ユーザーがコメントを入力するときにフッターのサイズをリロードするために、以前はこれをUITableView
使用beginUpdates
し、使用していました。endUpdates
私collectionView
はフッターをリロードするためにいくつかの異なる方法を試しましたが、ビューは元の位置までスクロールし、textView をキーボードの下に隠します。キーボードの上を維持し、UITextView
新しい行ごとに展開しようとしています。
- (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);
}