我正在使用此方法向下滚动 UIscrollView:
CGPoint bottomOffset = CGPointMake(0, self.ScrollForComments.contentSize.height - self.ScrollForComments.bounds.size.height);
[self.ScrollForComments setContentOffset:bottomOffset animated:YES];
要点是,如果 UIsecollView 中的内容大于 ScrollView 的实际大小,则一切正常,但如果内容较少,则此方法会隐藏 ScrollView 中的所有内容。我怎样才能阻止这个?
最佳答案
如果它太短而无法滚动,为什么要滚动它?相反,检查内容大小是否高于 ScrollView 大小:
if (self.ScrollForComments.contentSize.height > self.ScrollForComments.bounds.size.height) {
// if it is, run your code
CGPoint bottomOffset = CGPointMake(0, self.ScrollForComments.contentSize.height - self.ScrollForComments.bounds.size.height);
[self.ScrollForComments setContentOffset:bottomOffset animated:YES];
} else {
// if it is not, either do nothing or scroll to the top
}
关于ios - UIScrollView 向下滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14880770/