我有一个UIScrollView
,scrollview.contentSize
设置为UIScrollView
中所有子视图的高度。当contentSize
的高度大于UIScrollView
的高度时,在拖动视图时它可以完美滚动。当contentSize
的高度小于UIScrollView
的高度时,拖动视图时不会发生任何事情。
我认为这是标准行为,因为实际上没有可滚动的内容。但我希望UIScrollView
仍然能够移动一点。
一个可能的解决方案是确保contentSize
的高度永远不小于frame.height加上一个小间距(例如5像素):
CGSize scrollSize = self.frame.size;
int defaultHeight = self.frame.size.height + 5;
int contentHeight = self.webView.frame.origin.y + self.webView.frame.size.height;
scrollSize.height = MAX(defaultHeight, contentHeight);
[self.scrollView setContentSize:scrollSize];
有没有更少 hack 的方法来做这件事呢?
scrollEnabled
为YES
,是吗? - Sergey KalinichenkoscrollEnabled=YES
没有起作用。 - dhrm