XCode Interface Builder:更改已放置对象的类 [英] XCode Interface Builder: Change class of already placed object

查看:104
本文介绍了XCode Interface Builder:更改已放置对象的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有办法吗?我不仅要设置类标识,还要更改设计类(因此对象属性应该更改)。

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

原因是我放置了 UIView 和很多子视图。现在我想将其更改为 UITableViewCell 。也许它可以通过'黑客'xib文件来完成?

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?

推荐答案

不幸的是,令人抓狂的是,在InterfaceBuilder(我找到)中无法做到这一点。更改自定义类只是向UIView添加一个自定义类,而不是将UIView更改为您希望它的类(例如,UITableViewCell),带来您想要的视图可能具有的所有属性。您可以在storyboard的XML文件中看到这一点。

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.

您想要这样:

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

而不是:

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

但Xcode只给你后者;它更新了视图的customClass属性而不是更新整个元素。

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

如果你想要先前的,你仍然可以得到它,但是你必须编辑xml归档自己,保持元素的id相同。这是一篇很棒的博客文章,更详细地解释了这一点: http://codenetwaves.blogspot.com.br/2012/09/change-view-to-scrollview-in-xcode.html

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

这篇关于XCode Interface Builder:更改已放置对象的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆