Reputation: 2153
I have a view that contains 15 images and labels . I ve put them all on view but in some cases I don t want to show them all . For example I have IBOutlet UIImageView* image1 ; ....................* image2 ; ...................... .....................*imagen;
I have a list with objects but if i don t have n objects and i have just m i don t want to show images from m to n. In for loop I would like to have something - > string componentToShow = "image" + i ; and now (componentToShow).....set to visible and diffrent prop .
Thanks, Raluca
Upvotes: 0
Views: 39
Reputation: 73946
If I understand you correctly, you've got a varying number of objects, and you want to display accompanying views for the objects you have. You have laid out the maximum number of accompanying views in a nib file, and are now struggling with hiding the ones you don't want. Is that correct?
I would do it like this:
Take the accompanying views out of the nib. Create a second nib that represents a single object (e.g. label and image together). In your view controller's viewDidLoad
method, load the nib representing an object and store it in an instance variable. When an event happens that creates a new object, instantiate the nib and add the views produced to your view controller's view hierarchy.
Alternatively, if your representation of objects is simple enough, skip the second nib, and simply create the views directly in code.
Upvotes: 1