Xcode:如何转到滚动视图中的特定位置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8146776/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 22:26:41  来源:igfitidea点击:

Xcode: How to go to specific position in a scrollview

xcodeuiscrollviewuiimage

提问by Clarence

I am having problem when making a long scroll view with images. It will be difficult for users to scroll down for so long to get to that image or button. Is there any ways that i can create some buttons on the top of the scroll view, while pressing these buttons that can directly scroll down to the specific position that i want? (scroll down animated will be good)

使用图像制作长滚动视图时遇到问题。用户很难向下滚动这么长时间才能找到该图像或按钮。有什么方法可以在滚动视图的顶部创建一些按钮,同时按下这些按钮可以直接向下滚动到我想要的特定位置?(向下滚动动画会很好)

Many thanks.

非常感谢。

回答by mayuur

- (IBAction) yourBtnInScrollViewPressed : (id) sender
{
        [yourScrollView scrollRectToVisible:CGRectMake(x, y, yourScrollView.frame.size.width, yourScrollView.frame.size.height) animated:YES];

}