开发者

How to call a server image on an imageview programmatically?

开发者 https://www.devze.com 2023-03-28 04:26 出处:网络
I have an application in which I am displaying image in my imageview which comes from my XML parsing. I have created a custom tableview cell. Then I have created a global variable which will hold my i

I have an application in which I am displaying image in my imageview which comes from my XML parsing. I have created a custom tableview cell. Then I have created a global variable which will hold my image value that will come through xml parsing and this global variable I am setting on my imageview

This is my code:

//first image is my global variable which holds my xmlparser value
firstimage =cond1.Icon

firstviewimage = [[UIImageView alloc] init];
    //[image1 setImage:[UIImage imageNamed:mWeatherImg]];
    [firstviewimage setBackgroundColor:[UIColor grayColor]];
    [firstviewimage setFrame:CGRectMake(50,30, 40, 40)];
    firstviewimage.image= (UIImage*)firstimage;

    // firstviewimage is my imageview where i am setting my global
    // variable.in my global variable the value  of the server image
    // is getting passed but that i开发者_开发知识库mage is not getting set to my imageview. 
    // My app crashes giving an error in the console that [NSCFString scale]:
    // unrecognized selector sent to instance 0x4e2dce0'

[firstview addSubview:firstviewimage];


firstviewimage.image= [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.domain.com/ururlofImage.png"]]];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号