Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update UIView class in Interface Builder

I'm building a UI in XCode interface builder. After having layed out the required view hierarchy, I realised that one of the views closer to the top of the hierarchy should be a UIScrollView and not a UIView.

Is there any way to easily change that view's type from UIView to UIScrollView without having to re-layout all the child components with their own sub-view hierarchies?

like image 933
Aleks G Avatar asked May 23 '12 16:05

Aleks G


1 Answers

The simplest way as I know is right click the the corresponding .xib file and select Opern As --> Source Code. Then you can find out the view you want to change. It'll looks like this.

<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="0gr-sH-vvn">
.
.
.
</view>

Change it as

<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="0gr-sH-vvn">
.
.
.
</scrollView>

Basically you need to change the view to scrollView and other attributes will be auto generate when you are changing them via Attribute inspector section under interface builder mood ( Right click the the.xib file and select Opern As --> Interface Builder XIB Document )

like image 84
enadun Avatar answered Oct 09 '22 02:10

enadun