0

所以,我在UIWebView. 理想情况下,用户可以选择用手指或点击按钮滚动浏览它。就像当他们点击按钮时,它会向下滚动一英寸左右。这是我正在使用的代码(感谢 danypata):

    //Scroll Up:
-(IBAction)scrollContentUp:(id)sender {

    [_viewWeb.scrollView setContentOffset:_viewWeb.scrollView.contentOffset.y - 10.0 animated:YES];
}

//Scroll down:
-(IBAction)scrollContentDown:(id)sender {
    [_viewWeb.scrollView setContentOffset:_viewWeb.scrollView.contentOffset.y + 10.0 animated:YES];
}

问题在于 10.0。我收到错误: Sending double to parameter of incompatible type CGPoint (aka struct CGPoint)

我以前从未使用过 CGPoints,并尝试过研究它们,但它超出了我的想象。有谁知道在这段代码中插入什么来实现滚动效果?

4

1 回答 1

1

在您的代码中,您在 CGpPoint 的位置传递浮点值,这就是您收到该错误的原因。contentOffset 值的设置CGPointMake(x,y)值。

[_viewWeb.scrollView setContentOffset:CGPointMake(0,_viewWeb.scrollView.contentOffset.y - 10.0) animated:YES];
于 2013-05-18T15:58:17.400 回答