進んでいます。この方法は、Kevin のアイデアに基づいて見つけました。アニメーションを YES に設定できるようにするために、UIScrollView のデリゲート メソッドを使用してアニメーションの最後をキャッチします。できます。しかし、2 つのアニメーションを実行しないのに役立つ解決策があれば、大歓迎です。これを行う方法について何か考えはありますか?
- (IBAction) scrollToToday:(BOOL)animate {
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:1] atScrollPosition:UITableViewScrollPositionTop animated:animate];
if (animate == NO) [self showFirstHeaderLine:NO];
}
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
[self showFirstHeaderLine:YES];
}
- (void) showFirstHeaderLine:(BOOL)animate {
CGRect headerRect = [self.tableView rectForHeaderInSection:1];
CGPoint scrollPoint = headerRect.origin;
scrollPoint.y -= headerRect.size.height;
[self.tableView setContentOffset:scrollPoint animated:animate];
}
このコードのおかげで、アニメーションが YES に設定されているときのプロセスは、scrollViewDidEndScrollingAnimation と showFirstHeaderLine の間で無限にループするはずです...ループします、はい、しかし一度だけ...理由について何か考えはありますか?