iPad: how can I create a repeatable UI element using Interface Builder?

痞子三分冷 提交于 2019-12-13 07:42:53

问题


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.

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

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.

Any ideas?


回答1:


  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.


来源:https://stackoverflow.com/questions/5572140/ipad-how-can-i-create-a-repeatable-ui-element-using-interface-builder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!