可能的重复:
以编程方式滚动 UIScrollView https://stackoverflow.com/questions/2234875/programmatically-scroll-a-uiscrollview
目前,我正在开发一个应用程序,其中我有UIScrollView
并且一些按钮以编程方式插入scroll view.Scrolling
这些添加的按钮对我来说效果很好。但我想添加两个
更多按钮和一键单击scroll view scrolling
到底部并最后显示底部
按钮,当我单击第二个按钮时,它滚动到顶部并显示最上面的按钮。我已经尝试了很多但无法成功。我该如何解决这个问题?提前致谢。
scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 20, 320, 400)];
scrollView.backgroundColor=[UIColor lightGrayColor];
scrollView.contentSize=CGSizeMake(320, 500);
scrollView.showsVerticalScrollIndicator=YES;
[self.view addSubview:scrollView];
如果滚动大小已知,那么我们可以设置按钮单击事件
-(void)buttonCkicked:(UIButton*)sender
{
if (sender.tag==1001) {
[scrollView setContentOffset:CGPointMake(0, 100) animated:YES];
}
if (sender.tag==1002) {
[scrollView setContentOffset:CGPointMake(0, 0) animated:YES];
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)