我想要一个ScrollView在底部开始。任何方法?Iphone:ScrollView强制底部
我已经尝试过这一点,但我不能返回顶部....
CGPoint bottomOffset = CGPointMake(0, [yourScrollView contentSize].height);
[yourScrollView setContentOffset:bottomOffset animated:YES];
我想要一个ScrollView在底部开始。任何方法?Iphone:ScrollView强制底部
我已经尝试过这一点,但我不能返回顶部....
CGPoint bottomOffset = CGPointMake(0, [yourScrollView contentSize].height);
[yourScrollView setContentOffset:bottomOffset animated:YES];
我认为你必须使用
[self.catScroll scrollRectToVisible:CGRectMake(fr.frame.origin.x,0 , self.catScroll.frame.size.width, self.catScroll.frame.size.height) animated:NO];
其中catScroll
是滚动视图
或要使用setContentOffset:
将此属性更改为scrollView
的代理方法scrollViewDidEndDecelerating:
以新的内容偏移
我认为这一定会帮助你。
快乐编码:)
你应该叫
CGPoint bottomOffset = CGPointMake(0, [yourScrollView contentSize].height);
[yourScrollView setContentOffset:bottomOffset animated:NO];
在viewDidLoad中
。并检查yourScrollView
它应该正确连接到它的IBOutlet,或从[self.view viewWithTag:];
和contentSize
收到应设置为UIScrollView
内容大小,然后再尝试更改contentOffset
。
BTW,使其从开始你应该设置动画的底部:NO
如何使用scrollRectToVisible和CGRectMake? thx – user1471365
在这里我已经使用了水平滚动,所以我已经将它设置为x的框架原点看到答案的第一行只是把你想要在你的情况下可见的框架只是把CGRectMake(0,Content_Size在高度 - 滚动视图的高度,宽度,高度)把它放到scrollRectToVisible: –
我明白了!非常感谢你! – user1471365