iPad:如何使用Interface Builder创建可重复的UI元素? [英] iPad: how can I create a repeatable UI element using Interface Builder?

查看:107
本文介绍了iPad:如何使用Interface Builder创建可重复的UI元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Interface Builder中创建一个带有按钮和内容的面板。然后我想以编程方式克隆它并使用仿射变换重新定位克隆。

I want to make a panel in Interface Builder with buttons and stuff on it. Then I want to programmatically clone it and reposition the clones with affine transforms.

我正在考虑类似Flash中的MovieClip。

I'm thinking of something like a MovieClip from Flash.

仅仅多次渲染相同的UI元素是不够的。例如,应该可以在每个文本框中键入不同的内容。

And it isn't sufficient to just render the same UI element multiple times. For example, it should be possible to type something different in each text box.

任何想法?

推荐答案


  1. 创建一个包含自定义视图的新NIB文件。

  2. 创建 UINib 来自该NIB文件的实例 + [UINib nibWithNibName:bundle:]

  3. 每当你想创建一个新的查看,调用 - [UINib instantiateWithOwner:options:] 。此方法返回的数组包含NIB的所有顶级对象。因此,如果您创建的NIB文件仅包含视图,则该数组将此视图作为其唯一元素。确保将对象保留在数组中。

  1. Create a new NIB file that contains your custom view.
  2. Create a UINib instance from that NIB file with +[UINib nibWithNibName:bundle:].
  3. Whenever you want to create a new view, call -[UINib instantiateWithOwner:options:]. The array that this method returns contains all top-level objects of your NIB. So if the NIB file you created only consists of a view, the array contains this view as its only element. Make sure to retain the objects in the array.

这篇关于iPad:如何使用Interface Builder创建可重复的UI元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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