Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone:ScrollView强制到底部_Iphone_Objective C_Ios_Xcode_Scrollview - Fatal编程技术网

Iphone:ScrollView强制到底部

Iphone:ScrollView强制到底部,iphone,objective-c,ios,xcode,scrollview,Iphone,Objective C,Ios,Xcode,Scrollview,我想要一个滚动视图从底部开始。有什么办法吗 我已经试过了,但是我不能回到顶端 CGPoint bottomOffset = CGPointMake(0, [yourScrollView contentSize].height); [yourScrollView setContentOffset:bottomOffset animated:YES]; 你应该打电话 CGPoint bottomOffset = CGPointMake(0, [yourScrollView contentSize

我想要一个滚动视图从底部开始。有什么办法吗

我已经试过了,但是我不能回到顶端

CGPoint bottomOffset = CGPointMake(0, [yourScrollView contentSize].height);

[yourScrollView setContentOffset:bottomOffset animated:YES];
你应该打电话

CGPoint bottomOffset = CGPointMake(0, [yourScrollView contentSize].height); 
[yourScrollView setContentOffset:bottomOffset animated:NO];
在viewDidLoad中。并检查
yourScrollView
它应该正确连接到它的IBOutlet,或者从
[self.view view with tag:]接收contentOffset
之前,code>和
contentSize
应设置为
UIScrollView
内容大小


顺便说一句,要使它从一开始就处于底部,你应该设置动画:否,我想你必须使用

[self.catScroll scrollRectToVisible:CGRectMake(fr.frame.origin.x,0 , self.catScroll.frame.size.width, self.catScroll.frame.size.height) animated:NO];
其中
catScroll
是scrollView

或者使用
setContentOffset:
scrollView
的委托方法
ScrollViewDiEndDecreating:
中将此属性更改为新的contentoffset

我想这肯定会对你有帮助


快乐编码:)

这里我使用了水平滚动,所以我设置了它的帧原点x查看答案的第一行只需在您的案例中放置您希望可见的帧只需放置CGRectMake(0,高度滚动视图的高度、宽度、高度中的内容大小)将其放置为scrollRectToVisible:我找到了!非常感谢你!