Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode Interface Builder: Change class of already placed object

Is there a way to do it? I want not only set Class Identity but change designed class (so object properties should change).

The reason is that I placed UIView and a lot of subviews. Now I want to change it to UITableViewCell. Maybe it can be done by 'hacking' xib file?

like image 818
brigadir Avatar asked Sep 28 '12 17:09

brigadir


1 Answers

Unfortunately, maddeningly, there is no way to do this in InterfaceBuilder (that I have found). Changing the Custom Class just adds a custom class to the UIView, as opposed to changing the UIView to the class that you want it to be (e.g., UITableViewCell), bringing along all of the properties that your desired view may have. You can see this in the storyboard's XML file.

You want, say, this:

<label text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" ... id="Flb-Qd-jpJ"> ... </label>

and not this:

<view ... id="Flb-Qd-jpJ" customClass="UILabel"> ... </view>

but Xcode is only giving you the latter; it's updating the view's customClass attribute as opposed to updating the entire element.

If you want the prior, you can still get it, but you'd have to edit the xml file yourself, keeping the element's id the same. Here is a great blog article explaining this in more detail: http://codenetwaves.blogspot.com.br/2012/09/change-view-to-scrollview-in-xcode.html

like image 129
lillialexis Avatar answered Oct 31 '22 16:10

lillialexis