我有一个 UICollectionView
,里面有一个 UITextView
的自定义单元格。
用户可以点击文本字段内的任何文本。当文本字段的高度大于单元格的大小时,单元格会建议 Collection View 自行重新加载。
-(void)updatedCell:(UICollectionViewCell*)cellToUp{
NSIndexPath *indexPath = [self.collectionView indexPathForCell:cellToUpdateSize];
BOOL animationsEnabled = [UIView areAnimationsEnabled];
[UIView setAnimationsEnabled:NO];
[self.collectionView reloadItemsAtIndexPaths:[NSArray arrayWithObject:indexPath]];
[UIView setAnimationsEnabled:animationsEnabled];
}
问题是,当单元格“重新加载”时,键盘被关闭并再次显示,但没有任何关联的文本字段。 有什么解决方案可以避免关闭键盘吗?
提前致谢。
最佳答案
您可以覆盖 UICollectionView 上的重新加载函数。
类似于:
[super reloadData];
[textView becomeFirstResponder];
关于ios - 不要通过重新加载 collectionViewCell 关闭键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24742123/