我有一个应用程序,我在我的imageview中显示图像,该图像来自我的XML解析。我创建了一个自定义的tableview单元格。然后我创建了一个全局变量,它将保存我的图像值,该值将通过xml解析和我在imageview上设置的全局变量
这是我的代码:
//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 image 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];
答案 0 :(得分:0)
firstviewimage.image= [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.domain.com/ururlofImage.png"]]];