I am looking on how i can add an image i have in my project into my application onto my view "MainView", through code.
I have a button, and i want to make the image appear when i press the button.
Other info:
- Image is 320x480
- Image name is "crack.png"
- Image
is added into my project through XCode.
- I can make the image appear if i use the IB, i'm looking to do it through code.
- All i need to know is how to make the image appear, i have the action all set up.
Major beginner, any help?
Thanks, Steaps.
EDIT:
This always happens, you find the answer not after looking for an hour, but after you post a thread.
Code:
UIImage *image = [ UIImage imageNamed: @"crack.png" ];
UIImageView *imageView = [ [ UIImageView alloc ] initWithImage: image ];
imageView.frame = CGRectMake(0.0f, 0.0f, 320, 480); // Set the frame in which the UIImage should be drawn in.
[ self addSubview: imageView ];