iPad: how can I create a repeatable UI element using 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.
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?
- Create a new NIB file that contains your custom view.
- Create a
UINib
instance from that NIB file with+[UINib nibWithNibName:bundle:]
. - 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.
精彩评论