views:

169

answers:

1

Hi guys, I need a way of creating a UIView dynamically. Thus, the parent class could look for say a count of array items, and create UIViews on the fly of the amount of items in the array.

The views need to be allocated dynamically, do I can't create them on the fly.

Can you help?

+1  A: 

You can create them anytime.

UIView *myView = [[UIView alloc] initWithFrame:myFrameRect]

You can call this from within a loop, store the pointer in another array for further use or whatever you want. Just remember to release them when you are done. Otherwise you will be in a memory issue.

taskinoor
Not really what I was looking for, I need to create pointers dynamically, so the count in an array (NSArray) to be the number of UIViews created is the number of items in the array, and then I need to be able to refer to the UIViews by name (pointer).
Ollie