UICollectionView 中的 textview becomeFirstResponder 不起作用
textview becomeFirstResponder in UICollectionView not working
我在 UICollection 中遇到了问题,我有 4 个 indexPath(0 到 3)。当从 indexPath 2 到 3 我的 textView 仍然不会聚焦时,我已经尝试了所有文章但仍然卡住了,否则我的一些朋友说因为单元格为零?
这是我的代码:http://pasted.co/90c7f3d9
抱歉有人删除了我的代码。
我的前辈找到了解决方案,当你使用 animateWithDuration 并想要显示键盘时,应该在 "animateWithDuration" 中输入 becomeFirstResponder 和 "Completion",这是解决方案:
[UIView animateWithDuration:0.3f animations:^{
[self.rateReviewExpertView.collectionView setContentOffset:CGPointMake(3.0f*(CGRectGetWidth([UIScreen mainScreen].bounds)), 0.0f)];
}completion:^(BOOL finished) {
RateReviewExpertCollectionViewCell *cell = (RateReviewExpertCollectionViewCell *)[self.rateReviewExpertView.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:3 inSection:0]];
[cell.textView becomeFirstResponder];
}];
我在 UICollection 中遇到了问题,我有 4 个 indexPath(0 到 3)。当从 indexPath 2 到 3 我的 textView 仍然不会聚焦时,我已经尝试了所有文章但仍然卡住了,否则我的一些朋友说因为单元格为零?
这是我的代码:http://pasted.co/90c7f3d9
抱歉有人删除了我的代码。
我的前辈找到了解决方案,当你使用 animateWithDuration 并想要显示键盘时,应该在 "animateWithDuration" 中输入 becomeFirstResponder 和 "Completion",这是解决方案:
[UIView animateWithDuration:0.3f animations:^{
[self.rateReviewExpertView.collectionView setContentOffset:CGPointMake(3.0f*(CGRectGetWidth([UIScreen mainScreen].bounds)), 0.0f)];
}completion:^(BOOL finished) {
RateReviewExpertCollectionViewCell *cell = (RateReviewExpertCollectionViewCell *)[self.rateReviewExpertView.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:3 inSection:0]];
[cell.textView becomeFirstResponder];
}];