I need to create a a bunch a views on the fly. I was wondering what would be the best way to go about doing this as ill need to define coordinates, tag, colours of each view.
Would i need to create a multidimensional array and if so how can i do this?
CGRect viewRect1 = { 80.0, 200.0, 160.0, 100.0 };
UIview *myview1 = [[UIview alloc] initWithFrame:viewRect1];
[myview1 setBackgroundColor:[UIColor darkGrayColor]];
You need to define a structure to hold the data which is needed to create your
UIView.Then create an object of above class AND assign the values in member then add that in your
NSArray…EDITED:
In MyViewDataHolder.h class
In MyViewDataHolder.mm class
Now How to use it ….
Create objects of
MyViewDataHolderlike below …Create as much as you need
Then Create an
NSMutableArrayand add each objects ofMyViewDataHolderintoNSMutableArray.When you need the stored info you could use as below …
The code reflect the approach , Although I didn’t compile the code So use it as reference
Thanks ,