UIScrollView not scrolling in Swift

前端 未结 12 1020
Happy的楠姐
Happy的楠姐 2021-02-03 19:03

My UIScrollView won\'t scroll down. I don\'t know why. I already followed Apple documentation regarding to this issue.

@IBOutlet weak var scroller: UIScrollView!         


        
12条回答
  •  不知归路
    2021-02-03 19:20

    The problem could be that your scrollView doesn't know its contentSize like stated above, but the fix is easier than what the above answers are. Like Carlos said but I will elaborate more. If you want your scrollView to scroll vertically(up & down), make your contentView which is in the hierarchy of the scrollView equal width to the ViewController and give it a height constraint that works for your project i.e. 700. For the opposite(horizontally) make the height equal to the ViewController and the width some big number that works for your project.

提交回复
热议问题