以编程方式从左到右反向滚动 UIScrollView

mhe*_*gon 1 reverse uiscrollview right-to-left ios

我试图从左到右自动滚动,但我还没有成功。我正在评估以下表达式以改变方向(添加或减去像素)但是当滚动到达最终它被阻止...

(xContentSize - xOffset) >= CGRectGetWidth(_scroll.bounds)
Run Code Online (Sandbox Code Playgroud)

或者

(xContentSize - xOffset) > CGRectGetWidth(_scroll.bounds)
Run Code Online (Sandbox Code Playgroud)

任何的想法?

Dha*_*ekh 5

尝试这个:

float w = scrollView.frame.size.width;
float h = scrollView.frame.size.height;
float newPosition = scrollView.contentOffset.x+w; 
CGRect toVisible = CGRectMake(newPosition, 0, w, h);

[scrollView scrollRectToVisible:toVisible animated:YES];
Run Code Online (Sandbox Code Playgroud)

手动设置您想要的位置