Thursday 15 August 2013

ios - Cloning a uiview defined in interfacebuilder? -


I have a UIView built in an interface builder, which is a subviewview of Scrollview. UIView has a button and a label. I would like to use this view as a cookie cutter so that I can produce different examples of this view of the coalition next to each other in ScrollView.

I can do this program but this means That I have to define projectmatically in terms of visual size and subprints programmatically, what I like to do, define an example of the scene in the interface builder Shall do, so I am able to make it out and then the program copies of the footage. Its goal is to define the layout to reduce the code as much as possible of the interface builder, which I have to write.

I have created a UIView square to manage it. @interface UIView (JLTDeepClone) - (ID) deepClone; @end @ Implementation UIView (JLTPP Clone) - (ID) DeepClone {NSMUtableData * Data = [NSMUtableData Data]; NSKeyedArchiver * archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData: data]; [Collector encoded object: key for self: @ "view"]; [Archive end encoding]; NSKeyedUnarchiver * unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData: data]; UIView * Result = [unarchiver decodeObjectForKey: @ "View"]; [Autocomplete finish decoding]; Return result; } @end

No comments:

Post a Comment