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 > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-26-2010, 11:05 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 36
n2pb is on a distinguished road
Default Loading a UIImage from the web in IOS4

Another little quirk I've noticed in the change from IOS3 to IOS4 is that whenever I attempt to go ahead and load an image dynamically from the web my app crashes.

Code:
- (void) viewDidLoad
{
	NSURL *url = [NSURL URLWithString:@"http://assets.strose.edu/mobileweb/potd2/GetPhotoOfTheDay.ashx?id=1196"];
	UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
	imgPOTD.image = image;
}
It seems a lot of the old things I used to do have now been broken.
Any way to get this to work in OS4?

Thanks,
Justin
n2pb is offline   Reply With Quote
Old 07-26-2010, 11:43 AM   #2 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 36
n2pb is on a distinguished road
Default

Quote:
Originally Posted by n2pb View Post
Another little quirk I've noticed in the change from IOS3 to IOS4 is that whenever I attempt to go ahead and load an image dynamically from the web my app crashes.

Code:
- (void) viewDidLoad
{
	NSURL *url = [NSURL URLWithString:@"http://assets.strose.edu/mobileweb/potd2/GetPhotoOfTheDay.ashx?id=1196"];
	UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
	imgPOTD.image = image;
}
It seems a lot of the old things I used to do have now been broken.
Any way to get this to work in OS4?

Thanks,
Justin

I actually just noticed this still crashes is whenever I connect the UIImageView to it's outlet in Interface Builder even if the code inside viewDidLoad is commented out. But if it is not connected then it doesn't crash.

Any ideas?

- Justin
n2pb is offline   Reply With Quote
Old 07-26-2010, 12:35 PM   #3 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

It would be useful to know what the crash message is.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 07-26-2010, 12:37 PM   #4 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 36
n2pb is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
It would be useful to know what the crash message is.
No message is given.
I'm just testing it in the Simulator.
The second I open the app, it loads the splash screen then immediately dies.
n2pb is offline   Reply With Quote
Old 07-26-2010, 12:38 PM   #5 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Start adding logs to figure out where it dies, then.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 07-26-2010, 12:55 PM   #6 (permalink)
iPhone SDK fanatics!
 
Join Date: Aug 2009
Location: Malaysia
Posts: 405
KennyChong is on a distinguished road
Default

Quote:
Originally Posted by n2pb View Post
Another little quirk I've noticed in the change from IOS3 to IOS4 is that whenever I attempt to go ahead and load an image dynamically from the web my app crashes.

Code:
- (void) viewDidLoad
{
	NSURL *url = [NSURL URLWithString:@"http://assets.strose.edu/mobileweb/potd2/GetPhotoOfTheDay.ashx?id=1196"];
	UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
	imgPOTD.image = image;
}
It seems a lot of the old things I used to do have now been broken.
Any way to get this to work in OS4?

Thanks,
Justin

This works for me. Try it.

id path = @"http://merrimusings.mu.nu/archives/images/groundhog2.jpg";
NSURL *url = [NSURL URLWithStringath];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data cache:NO];
__________________
KennyChong
iPhone SDK Fanatic!
KennyChong is offline   Reply With Quote
Old 07-26-2010, 01:35 PM   #7 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 36
n2pb is on a distinguished road
Default

Quote:
Originally Posted by KennyChong View Post
This works for me. Try it.

id path = @"http://merrimusings.mu.nu/archives/images/groundhog2.jpg";
NSURL *url = [NSURL URLWithStringath];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data cache:NO];
I'm a complete idiot.
Monday morning detail for ya.
In my tab bar, I updated the xib file to reflect the new one, but i never updated the class of the tab on the tab bar.
Hence why everything was fine and dandy until I attempted to load/edit something on that tab.

Thanks for your help guys!
n2pb is offline   Reply With Quote
Old 07-26-2010, 03:01 PM   #8 (permalink)
iPhone SDK fanatics!
 
Join Date: Aug 2009
Location: Malaysia
Posts: 405
KennyChong is on a distinguished road
Default

Quote:
Originally Posted by n2pb View Post
I'm a complete idiot.
Monday morning detail for ya.
In my tab bar, I updated the xib file to reflect the new one, but i never updated the class of the tab on the tab bar.
Hence why everything was fine and dandy until I attempted to load/edit something on that tab.

Thanks for your help guys!
Haha...typical monday blues....cheers.
__________________
KennyChong
iPhone SDK Fanatic!
KennyChong is offline   Reply With Quote
Reply

Bookmarks

Tags
dynamic, ios4, uiimageview, web

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



» Advertisements
» Online Users: 348
14 members and 334 guests
alexP, appservice, bignoggins, EXOPTENDAELAX, guusleijsten, Hamad, heshiming, mariano_donati, Objective Zero, ohmniac, Paul Slocum, Rudy, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,653
Threads: 94,115
Posts: 402,888
Top Poster: BrianSlick (7,990)
Welcome to our newest member, ohmniac
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:43 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0