Reputation: 315
I'm trying to make a class (ScrollableView : UIScrollView) that can always scroll vertically, similar to a 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; it will only work if the value is 4 or more.
- (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.
Upvotes: 16
Views: 5277
Reputation: 2862
How about setting
alwaysBounceVertical = YES
In Swift:
scrollView.alwaysBounceVertical = true
Upvotes: 43