UIViewControllerにUITableViewがあります。そして、この表には、5つの表示可能なカテゴリから選択する「言う」があります。しかし、コンテンツを保持する配列には、「言う」10のカテゴリがあります。私が今作成したのは、インデックス0のカテゴリ1からインデックス9のカテゴリ10に移動する通常のスクロールテーブルです。しかし、私が欲しいのは、カテゴリ10の後のカテゴリ1とその逆です。
つまり、基本的には静的配列の無限ループです。
私はscrollViewDidScroll:メソッドでこれを試しましたが、そうすると、UITableViewがスクロールするのと同じようにスクロールしません。ランダムな場所にRACESし、1つまたは2つのカテゴリを移動することは不可能です。
これが私のコードのサンプルです。誰かが助けてくれることを願っています。
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (scrollView == categoryView){
if (categoryView.contentOffset.y > 0.0) {
loopcounter++;
NSLog(@"ScrollView Scrolled DOWN");
[categorytablecontent insertObject:[categorytablecontent objectAtIndex:0] atIndex:[categorytablecontent count]-1];
[categorytablecontent removeObjectAtIndex:0];
[categoryView reloadData];
}
if (categoryView.contentOffset.y < 0.0) {
loopcounter = [categorytablecontent count];
NSLog(@"ScrollView Scrolled UP");
[categorytablecontent insertObject:[categorytablecontent objectAtIndex:[categorytablecontent count]-1] atIndex:0];
[categorytablecontent removeObjectAtIndex:[categorytablecontent count]-1];
[categoryView reloadData];
}
a = categoryView.visibleCells;
for (UITableViewCell *cell in a){
NSLog(@"Current Visible cell: %@", cell.textLabel.text);
}
NSLog(@"Current offset: %@", categoryView.contentOffset.y);
}
}