I have created a storyboard based project. In one of the view controller's view requires some extra elements to be placed which results in increasing the view height such that the view must now be scrollable. Is it possible to simply change the class type of UIView to UIScrollView in storyboard? Will it really convert the top level UIView to UIScrollView ? Just looking for a quick and easy way of doing this without much changes.
Thanks
You can open storyboard as an xml source code file, find view object and replace it with scrollview. Right-click on .storyboard
file in Xcode and choose Open As → Source Code. Then search for your scene's xml snippet (for example, Cmd+F and type controllers name). Top view object will look like this:
<view key="view" contentMode="scaleToFill" id="Jjm-HD-A8W">
...
(suviews and constraints)
...
</view>
Change view
element to scrollView
(don't forget the closing tag):
<scrollView key="view" contentMode="scaleToFill" id="Jjm-HD-A8W">
...
(suviews and constraints)
...
</scrollView>
Then open .storyboard
with the Interface Builder. Your view now became a scrollview.
This method has two advantages: you don't loose any constraints and you see all scrollview specific properties in the attributes inspector.
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