Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 12-20-2008, 12:54 AM   #1 (permalink)
Steaps
Tutorial Author
 
Steaps's Avatar
 
Join Date: Oct 2008
Location: Ontario, Canada
Posts: 464
Steaps is on a distinguished road
Red face Inserting An Image (Without IB)

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 ];

Last edited by Steaps; 12-20-2008 at 01:08 AM.
Steaps is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,605
Threads: 94,084
Posts: 402,783
Top Poster: BrianSlick (7,990)
Welcome to our newest member, champa812
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:14 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.