Reputation: 57
I would like to know if i can put a view into a NSMutableArray, working with UIPageControl and ScrollView.
Upvotes: 0
Views: 1856
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
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
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