Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-14-2008, 05:13 AM
Administrator
 
Join Date: Jun 2008
Location: Arizona
Posts: 395
Send a message via AIM to mxweas Send a message via Yahoo to mxweas Send a message via Skype™ to mxweas
Default Displaying an image from the web or the application bundle

First a UIImage needs to be made, to make one with an image from the application bundle use this code:
Code:
UIImage *myImage = [ UIImage imageNamed: @"myImage.png" ];
If you need to make an image from a URL you can do something like this:
More info can be found about this technique here: One line UIImage from URL
Code:
UIImage *myImage = [UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString: @"http://img.youtube.com/vi/OhOahwZCO1s/2.jpg"]]];
Now that the UIImage has been made it needs to be put into a UIImageView. This is simply done with the -initWithImage: method:
Code:
UIImageView *myImageView = [ [ UIImageView alloc ] initWithImage: myImage ];
You can then add the image view as a subview to any other view. You can also change the frame to resize the image.

Max
Reply With Quote
  #2 (permalink)  
Old 08-24-2008, 10:41 PM
pm7 pm7 is offline
Member
 
Join Date: Aug 2008
Posts: 65
Default

If you have an Imageview initialized with an image, and during the execution of your code, you would like to change the image hold by the imageView, what code would you use?

TX
Reply With Quote
  #3 (permalink)  
Old 08-24-2008, 10:46 PM
Administrator
 
Join Date: Jun 2008
Location: Arizona
Posts: 395
Send a message via AIM to mxweas Send a message via Yahoo to mxweas Send a message via Skype™ to mxweas
Default

Just change the image property:
Code:
myImageView.image = myNewUIImage;
Max
Reply With Quote
  #4 (permalink)  
Old 08-25-2008, 01:46 AM
Administrator
 
Join Date: Jun 2008
Location: Arizona
Posts: 395
Send a message via AIM to mxweas Send a message via Yahoo to mxweas Send a message via Skype™ to mxweas
Default

I've removed all posts not pertaining to this thread now that the problem has been solved. Please keep programming questions to the General section.

Max
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:50 AM.