如何在UIScrollView中禁用垂直滚动?
UIScrollView有一个属性scrollEnabled来禁用所有的滚动,但我只想禁用垂直滚动。
那可能吗? 谢谢。
如果scrollView的contentSize.height
小于bounds.size.height
,它将不会垂直滚动。
尝试设置:
scrollView.contentSize = (CGSize){<yourContentWidth>, 1.0}
迅速
scrollView.contentSize = CGSize(width: <yourContentWidth>, height: 1.0)
- (void)scrollViewDidScroll:(UIScrollView *)aScrollView { [aScrollView setContentOffset: CGPointMake(aScrollView.contentOffset.x,0)]; }
你必须已经确认到UIScrollViewDelegate
aScrollView.delegate = self;