views:

31

answers:

1

I was helped here a while ago about loading images from an array, but would like to know the exact details please.

Where does the code go if my app will be as simple as images that load from an array depending on whether the user chose the next or previous button? Does it go in the View Controller class?

What do I need if I literally just need one view which displays a full screen image and the image gets changed depending on the user choice, like I mentioned above?

Thanks in advance

Regards

A: 

The view controller is responsible for controlling the view (receiving events from it, doing something then passing back data to it).

That said you can store your array in the view controller or in some other model class. Either way the view controller will be responsible for taking an image from this array and giving it to the view when it receives user input.

You just need to place a UIImageView in your view controller's view. Then assuming you're using IB you create an IBOutlet property in your controller to have a handle on this image view.

Then you need to get events from your user (either a button, or some other touch) and assign it to an IBAction that your controller can handle. When you handle the action you can remove the old image and assign a new image from your array to your UIImageView.

That's about as detailed as I can go given your current question. If you need more information please give more detail.

Nebs
Best answer I could have been given. nice1.If I need more help I will ask. Thanks
alJaree
Could you please give me an example of assigning an image to UIImageView. I have added the UIImageView using IB, but I cannot see the code which adds this when I look in the classes?
alJaree
Look at UIImageView's 'image' property. You just pass it a UIImage.
Nebs