jiffywang : 把scrollview的delegate設置成viewcontroller:ide
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {code
CGPoint offset = scrollViewB.contentOffset;it
offset.y = scrollViewA.contentOffset.y;class
[scrollViewB setContentOffset:offset];scroll
}margin
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {di
if([scrollView isEqual:scrollViewA]) {view
CGPoint offset = scrollViewB.contentOffset;vi
offset.y = scrollViewA.contentOffset.y;co
[scrollViewB setContentOffset:offset];
} else {
CGPoint offset = scrollViewA.contentOffset;
offset.y = scrollViewB.contentOffset.y;
[scrollViewA setContentOffset:offset];
}
}
- (void)matchScrollView:(UIScrollView *)first toScrollView:(UIScrollView *)second {
CGPoint offset = first.contentOffset;
offset.y = second.contentOffset.y;
[first setContentOffset:offset];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if([scrollView isEqual:scrollViewA]) {
[self matchScrollView:scrollViewB toScrollView:scrollViewA];
} else {
[self matchScrollView:scrollViewA toScrollView:scrollViewB];
}
}