João Victor
João Victor

Reputation: 57

Adding Views into a Mutable Array

I would like to know if i can put a view into a NSMutableArray, working with UIPageControl and ScrollView.

Upvotes: 0

Views: 1856

Answers (3)

Sj.
Sj.

Reputation: 1724

You can add any sort of Objects to your Array/ Dictionary. Basically all the views are objects. So you can simply add it like any other object. eg. [myArray addObject:myViewObject]. But Inorder to add objects dynamically you must define the Array/ Dictionary as Mutable. (ie, NSMutableArray or NSMutableDictionary)

Upvotes: 0

Olotiar
Olotiar

Reputation: 3274

You can put a UIView into a NSMutableArray by just calling addObject, but that won't achieve very much, what you're probably trying to do is to display a bunch of UIView into a UIScrollView with pagination enabled, and a UIPageControl, a process which is described here

Upvotes: 0

Midhun MP
Midhun MP

Reputation: 107191

Answer is Yes. You can add any type of object to NSMutableArray.

UIView *tempView = [[UIView alloc] init];
[yourArray addObject:tempView];
[tempView release];

Upvotes: 2

Related Questions