Crimson1222
Crimson1222

Reputation: 297

Making UIView Scrollable without UIScrollView

Basically, what I'm trying to do is make the normal UIView scrollable (no UIScrollView). When my app changes orientation from portrait to landscape, the content that falls below the bottom boundary becomes inaccessible. When I tried to use UIScrollView, I still couldn't access the content below the bottom boundary and the ScrollView didn't resize to follow the constraints I set for it.

Can someone help me make a UIView scrollable?

Upvotes: 7

Views: 7708

Answers (2)

iSkore
iSkore

Reputation: 7553

You can make a UIView scrollable but not in a conventional way. As @colinrf said, that's what a UIScrollView is for. But, for example, you can make a UIView twice the height of the screen, then subtract and add the Y value of the Rect in accordance with the UITouch movements. For instance, if the touch location (delta if you want) is moving negative from middle of the screen to the top, move the Y value negatively as well. You can do it by UIGuestureSwipe too.

Upvotes: 3

colinrf
colinrf

Reputation: 263

You cannot make a UIView scrollable. That's what UIScrollView is for. However if you are using storyboards you can try to add constraints to the view so when you rotate the device the content remains inside the viewable area. Sounds like you already have some constraints setup so I would just play around with them. Sometimes it can take some tweaking to get them right.

Upvotes: 3

Related Questions