English 中文(简体)
更新接口构建器中的 UIView 类
原标题:Update UIView class in Interface Builder

我在 XCode 界面构建器中建立一个 UI 。 在设定了所需的视图等级后, 我意识到, 靠近该等级顶端的视图之一应该是 UIScrollView , 而不是 UIView

是否有办法可以轻易地改变这种观点, 从UIView到UIScrollView, 而不必用他们自己的子视图等级重置所有儿童组成部分?

最佳回答

是的, 请单击您想要更改的 < code> UIView 。 在选中它后, 打开身份检查器窗格 。

从身份检查员那里,你应该看到最上面命名为“类”的字段,以灰色字表示的当前值应该是“UIView”。

输入 UIScroll View 并点击 Enter 。

这将更新您的 Nib 文件以及我之前的 UIOView UIScrollView 。 此外, 如果您已经将视图连接到 IB Outlet , 请确定您更新了 IBoutlet 类定义, 如果它不是 id

问题回答

据我所知,最简单的方式是右键单击相应的.xib 文件,然后选择 Opern As -- & gt; source Code 。然后您可以找到您想要更改的视图。它看起来是这样的 。

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

换成

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

基本上,您需要将 view 更改为 scrollView ,当您在界面构建者情绪 < em> 下通过属性检查员部分修改这些属性时,其他属性将自动生成(右键单击.xib 文件,并选择 Opern As -- & gt;界面构建器 XIB Document )





相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签