[英]How to make UIScrollView always scrollable
I'm trying to make a class (ScrollableView : UIScrollView) that can always scroll vertically, similar to a TableView. 我正在尝试创建一个可以始终垂直滚动的类(ScrollableView:UIScrollView),类似于TableView。 I've hardcoded a constant value to add to the content size so that it can always be scrollable.
我已经硬编码了一个常量值来添加到内容大小,以便它始终可以滚动。 For some strange reason though, it won't work when the value is 1;
但是出于某些奇怪的原因,当值为1时它将不起作用; it will only work if the value is 4 or more.
它只有在值为4或更大时才有效。
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.contentSize = CGSizeMake(frame.size.width, frame.size.height+1);
self.scrollEnabled = YES;
}
return self;
}
Is there another way to do this? 还有另一种方法吗? This doesn't seem to be the proper way.
这似乎不是正确的方法。
How about setting 如何设置
alwaysBounceVertical = YES
In Swift: 在Swift中:
scrollView.alwaysBounceVertical = true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.