セルが画面上の特定のポイント (中央) を通過するたびに再生されるティック ノイズを実装する方法を探しています。
私はウェブ上に注いでいますが、どこから始めればよいかわかりませんか? どんな方向性でも素晴らしいでしょう(私のためにそれを解決する人を探しているのではなく、洞察やアドバイスだけです)
ありがとう!
アップデート:
あなたの方法を使用して実装したコードを次に示しますが、正しく機能しません。パラメータの何かが間違っていることを意味する「Tick」nslogを呼び出すことは決してないようです。テーブルビュー セルの高さは 100 ピクセルです。何かアドバイス?
- (void) scrollViewDidScroll:(UIScrollView *)scrollView {
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
self.myTimer = [NSTimer scheduledTimerWithTimeInterval:1/30.0 target:self selector:@selector(checkTableViewScrollPosition) userInfo:nil repeats:YES];
}
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
{
if (self.myTimer)
[self.myTimer invalidate];
self.myTimer = nil;
}
int currentContentOffset = 0;
int tableviewCellHeight = 100;
int thresholdValue = 50;
- (void) checkTableViewScrollPosition {
int contentOffsetValue = _contentTableView.contentOffset.y;
NSLog(@"%d", contentOffsetValue);
if ((contentOffsetValue + tableviewCellHeight / 2) % tableviewCellHeight <= thresholdValue && currentContentOffset != contentOffsetValue ) {
NSLog(@"Tick!");
NSLog(@"%d", contentOffsetValue);
currentContentOffset = _contentTableView.contentOffset.y;
}
}