问题描述
我想知道我是否可以通过单击 UIButton 来滚动 UIScrollView,如果可以,有人可以告诉我如何操作.
I would like to know if it is possible for me to scroll a UIScrollView on the click of a UIButton and if so, would someone be able to tell me how to.
目前我正在使用下面的代码来查看滚动视图的左侧是否有更多内容,如果有,则显示一个图像,告诉用户如果他们向左滚动,会有更多内容.我想实现一个功能,我添加一个 UIButton 而不是图像,当左侧有更多内容可用并且当用户单击按钮时,滚动视图将滚动到左侧.
currently I am using the below code to see if in the scrollview more content is there to its left and if it is there, display an image which would tell the users that there is more content if they scroll to the left. I would like to implement a functionality where I add a UIButton instead of the image and when more content is available on the left and when the user clicks the button, the scrollview would scroll to its left.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView1 {
if (scrollView1.contentOffset.x == scrollView1.contentSize.width - scrollView1.frame.size.width)
{
// reached the right
self.imageView.hidden = YES;
}
else
{
self.imageView.hidden = NO;
}
}
如果有人能帮我解决这个问题,那就太好了.
It would be great if someone could help me out on this.
推荐答案
我认为这很简单.使用:
That's pretty easy, I think. Use:
[scrollView1 setContentOffset:CGPointMake(x, 0) animated:YES];
其中 X 是 scrollView1.contentOffset.x + scrollView1.contentSize.width 的值.
Where X is the value of scrollView1.contentOffset.x + scrollView1.contentSize.width.
这篇关于单击按钮滚动 UIScrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)