你只需要更新第二滚动型
喜欢的东西的边界: -
CGRect updateTheViewWithBounds = viewToUpdate.bounds;
updateTheViewWithBounds.origin = scrolledView.contentOffset;
viewToUpdate.bounds = updateTheViewWithBounds;
这将做的工作。
至于从评论中可以看出,我会举一个小例子。
创建两个滚动视图到的UIViewController
scrollOne = [[UIScrollView alloc] init];
[scrollOne setBackgroundColor:[UIColor greenColor]];
[scrollOne setFrame:CGRectMake(10, 20, 200, 300)];
[scrollOne setContentSize:CGSizeMake(600, 600)];
scrollOne.delegate = self;
scrollTwo = [[UIScrollView alloc] init];
[scrollTwo setBackgroundColor:[UIColor redColor]];
[scrollTwo setFrame:CGRectMake(230, 20, 200, 300)];
[scrollTwo setContentSize:CGSizeMake(600, 600)];
scrollTwo.delegate = self;
[self.view addSubview:scrollOne];
[self.view addSubview:scrollTwo];
顺应UIScrollView的代表和实现了相同的。
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if([scrollView isEqual:scrollOne])
{
CGRect updateTheViewWithBounds = scrollOne.bounds;
updateTheViewWithBounds.origin = scrollOne.contentOffset;
scrollTwo.bounds = updateTheViewWithBounds;
[scrollTwo flashScrollIndicators];
}
else if([scrollView isEqual:scrollTwo])
{
CGRect updateTheViewWithBounds = scrollTwo.bounds;
updateTheViewWithBounds.origin = scrollTwo.contentOffset;
scrollOne.bounds = updateTheViewWithBounds;
[scrollOne flashScrollIndicators];
}
}
滚动任何上述scrollView将滚动scrollView。
这只会在一个滚动视图没有滚动时才起作用,对吗? :( – kohaXun 2013-03-14 13:09:59
每当第一个scrollview改变,在委托,更新相应的其他scrollView – 2013-03-14 13:41:47
你是什么意思?你的意思是scrollView:DidScroll委托方法吗?你知道我可以如何使用这种方法,仍然能够让scrollviews以不同的速度滚动? – kohaXun 2013-03-15 08:32:01