2016-05-12 11 views
0

ユーザーがテキストフィールドの編集を終了した後、コレクションビューを次のセルにスクロールしたいとします。テキストフィールドの編集が終了した後のスクロールコレクションビュー

私のテキストフィールドデリゲートメソッドが呼び出されていて、ボタンを押すとコレクションビューがスクロールできますが、これら2つを組み合わせても機能しません。

-(BOOL)textFieldShouldReturn:(UITextField*)textField { 
    [textField resignFirstResponder]; 
    NSArray *visibleItems = [self.collectionView indexPathsForVisibleItems]; 
    NSIndexPath *currentItem = [visibleItems objectAtIndex:0]; 
    NSIndexPath *nextItem = [NSIndexPath indexPathForItem:currentItem.item + 1 inSection:currentItem.section]; 
    [self.collectionView scrollToItemAtIndexPath:nextItem atScrollPosition:UICollectionViewScrollPositionRight animated:YES]; 
    return YES; 
} 

答えて

0

textFieldDidEndEditingメソッドを使用するよりも、テキストフィールドの編集が終了したときにスクロールしたい場合。

あなたは残念ながらあなたの出力
+0

、これはどちらか動作しません...このコードを試してみてください。 – iOS

+0

を得たバラージュVincze @

- (void)textFieldDidEndEditing:(UITextField *)textField { NSArray *visibleItems = [self.collectionView indexPathsForVisibleItems]; NSIndexPath *currentItem = [visibleItems objectAtIndex:0]; NSIndexPath *nextItem = [NSIndexPath indexPathForItem:currentItem.item + 1 inSection:currentItem.section]; [self.collectionView scrollToItemAtIndexPath:nextItem atScrollPosition:UICollectionViewScrollPositionRight animated:YES]; } 

+0

テキストフィールドでの編集が終了したら、スクロールビューの最後のセルを移動しますか? – iOS

関連する問題