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! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } override func viewDidLayoutSubviews() { scroller.scrollEnabled = true // Do any additional setup after loading the view scroller.contentSize = CGSizeMake(400, 2300) }
You need to set the frame of your UIScrollView so that it is less than the contentSize . Otherwise, it won't scroll.
To fix ScrollView Not scrolling with React Native, we wrap the content of the ScrollView with the ScrollView. to wrap ScrollView around the Text components that we render inside. As a result, we should see text inside and we can scroll up and down.
One way to do this is programmatically create an UIScrollView in your UIViewController . To control the scrollability you can set the ScrollView contentSize property.
You need to set the frame
of your UIScrollView
so that it is less than the contentSize
. Otherwise, it won't scroll.
Also, I would recommend that you add the following to your viewDidLoad
method:
scroller.contentSize = CGSize(width: 400, height: 2300)
Alot of the time the code is correct if you have followed a tutorial but what many beginners do not know is that the scrollView is NOT going to scroll normally through the simulator. It is suppose to scroll only when you press down on the mousepad and simultaneously scroll. Many Experienced XCode/Swift/Obj-C users are so use to doing this and so they do not know how it could possibly be overlooked by beginners. Ciao :-)
@IBOutlet weak var scrollView: UIScrollView! override func viewDidLoad() { super.viewDidLoad() view.addSubview(scrollView) // Do any additional setup after the view } override func viewWillLayoutSubviews(){ super.viewWillLayoutSubviews() scrollView.contentSize = CGSize(width: 375, height: 800) }
This code will work perfectly fine as long as you do what I said up above
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With