Reputation: 723
I want to add number of images from library to a view. The number we want to add to the view is not known. How can I allocate UIImageViews dynamically. And I also want to drag those imageviews on the UIView. Please help me.
Thanks in advance.
Upvotes: 0
Views: 1661
Reputation: 3973
Your 'question' consists of way too many parts (the dragging is a different question entirely, one I advice you to look up on Google). And the adding part is easy. The hard part is; where are you getting those images from? Assuming you have an array with image names, it would be something like this;
for( NSString *imageName in (NSArray *)imageNames )
{
UIImage *image = [UIImage imageNamed:imageName];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
// .. you might want to set a frame to your imageView .. //
[self.view addSubview:imageView];
[imageView release];
}
Of course, this is not what you want, but with the little information provided, it was the best I could do with my spare time.
Upvotes: 1