0

当 UIScrollview 在 scrollViewDidScroll 委托方法中滚动时,我正在做一个很酷的 CA3DTransform。当您使用手指滚动时,它可以完美运行,因此手动滚动时一切都很完美。

但是,当我以编程方式设置滚动视图 contentoffset 时,例如:

[scrollView setContentOffSet:CGPointMake(0,460) animated:YES];

它仍然调用委托方法scrollviewdidscroll,因此调用了相同的动画方法,所以我仍然看到正确的动画,但是,在动画期间和之后,视图的某些部分丢失了!我试图在所有东西上设置 layer.zPosition ,但它似乎没有帮助。应该没问题,因为手动滚动确实可以工作而不会丢失部分视图...以某种方式以编程方式调用此方法有所不同,我不知道为什么!

4

2 回答 2

0

Post your question in this way is not very clear, considering that with the delegate scrollViewDidScroll, I can print me the code, either manually or programmatically.

...
UIScrollView *sv = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 10, 320, 200)];
[sv setContentSize:CGSizeMake(640, 200)];
sv.delegate = self;
[sv setContentOffset:CGPointMake(320, 0) animated:YES];
[self.view addSubview:sv];
...

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    NSLog(@"---%@---", NSStringFromCGPoint(scrollView.contentOffset));
}

In this simple example, you can see that the delegate actually works. Excuse the simplicity of the answer, but the only question you ask is hard to give you help.

于 2012-04-06T14:04:28.407 回答
0

我有一个类似的问题(在使用滚动视图进行幻灯片放映的情况下),但通过使用scrollRectToVisible:NO(否表示没有动画)解决了它,并将其包装在 UIView 动画块中,我也将我的动画代码放在其中。

于 2012-06-26T11:04:43.110 回答