You must be logged in to post Login Register

Search 

use URL to display image

User Post

8:12 am
August 25, 2008


bobcubsfan

Member

Los Angeles

posts 11

1

Trying to display an image I have stored using my web host.

Normally to dispaly an image this works per Apple example:

view2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sample.tiff"]];

But instead of the image file <sample.tiff> I want to display the same image which is stored at

I have looked at the code for retrieving a URL in UICatalog, and can display the web page, but I cannot figure out how to display the image.

4:04 pm
August 25, 2008


hijinks

Member

posts 4

2

if view2 is a UIImageView


view2.image = [UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString:@"http://www.domain.com/image.jpg"]]];

I go over a lot of that is my JSON sections of my blog at



hope it helps

5:15 pm
August 25, 2008


bobcubsfan

Member

Los Angeles

posts 11

3

thanks for the reply.


This works:

view2 = [[UIImageView alloc] initWithImage:[UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString:@"http://www.schoenburg.com/my.TIF"]]]];

7:46 pm
August 25, 2008


Brandon

Admin

brandontreb

posts 40

4

Great find hijinks!

That looks like a great tutorial.  After the Todo List series, I will probably have some web service tutorials on icodeblog.  they will probably use XML-RPC. 

Thanks for contributing that resource!

11:30 pm
August 25, 2008


bobcubsfan

Member

Los Angeles

posts 11

5

Okay, I got it to work, but, and this should be simple, but then what is with iPhone programming?

After defining two strings, NSString *one; and NSString *two; and using @property etc… and @synthsize …

I cannot find a way to concantenate the strings. So if one=”Hello”; and two =”world”; I want the result to be

“Hello world” stored in one. I would think it might be: one=one + two; but that generates and error.


5:53 am
August 26, 2008


hijinks

Member

posts 4

6

The best way to do that is with a NSMutableString

NSMutableString *hello = [[NSMutableString alloc] initWithString:@"Hello"];

[hello appendString:@" World"];

7:54 am
August 26, 2008


bobcubsfan

Member

Los Angeles

posts 11

7

Hijinks,


Thanks again. Why does Apple make it so difficult to find things like appendString? Maybe I am missing something

but I just cannot seem to find a reference to key words like this.

2:58 pm
August 26, 2008


hijinks

Member

posts 4

8

it is right in the NSMutableString reference

Their docs aren't really meant for new programers from what I can see. I come from a C background so its a lot easier for me to grasp. I have also done years of PHP work and if you come from that type of background the docs can be difficult since PHP isn't really Object Oriented in design

11:10 pm
August 26, 2008


bobcubsfan

Member

Los Angeles

posts 11

9

Your example worked for me. This is Apple's

- (void)appendString:( *)aString

The problem is that this is method which as I understand it cannot be placed inside another method. Apple also does

not give examples. I have programmed in Visual Basic, Visual FoxPro and PHP. The first two are objective in that you

might have a statement like this:

myText.Bold =TRUE; or myText.font =”Times Roman”;

Thanks again.


About the iCodeBlog forum

Currently Online:

1 Guest

Maximum Online: 7

Forums:

Groups: 2

Forums: 6

Topics: 50

Posts: 199

Members:

There are 105 members

There are 1 guests


Brandon has made 40 posts

Top Posters:

crazyiez - 26

Uhu - 17

bobcubsfan - 11

Nick - 9

jazzmic - 6

Administrator: Brandon


© - Version 3.1.3 (Build 356)  

Share and Enjoy: