图像不显示在服务器上

时间:2023-01-04 03:41:08

hello i am trying to fetch image from server in view . The link is here

你好,我试图从视图中的服务器获取图像。链接在这里

(image_file_name":"SPORTS DAY.jpg","image_file_path":"/file?key=AMIfv94Kr4jhI3rvj_91litYhNea5Z0B0gtf5sT-yyPlleesStjvlN-F7OnE3ZNq2Zsz_M41UduLEi6oWjY1wckzf6zMd-2HKptNAiAmHpoUIT2rzIcbGThFR8VXAadjm5E-il-uorOaNcWWmyyy8ykveoxwI-swvw&download=false"})

and my code is here

我的代码就在这里

 UIImage *img =[UIImage imageNamed:[NSURL URLWithString:[(NSMutableDictionary *)[SharedPreferenceUtil getNSObject:STUDENT_DATA_JSON] valueForKey:@"image_file_name"]]];

 cell.imageView.image=img;

please solve this.

请解决这个问题。

1 个解决方案

#1


The method imageNamed: of UIImage you are using loads the local image, i.e. image that's contained in you app's bundle. In order to load image from the server, you have to use different techniques, like:

您正在使用的UIImage方法imageNamed:加载本地图像,即您应用程序包中包含的图像。要从服务器加载图像,您必须使用不同的技术,例如:

NSData *imageData = [NSData dataWithContentsOfURL:[NSURL urlWithString:{image_url}]]; 
UIImage *image = [UIImage imageWithData:imageData];

and then use image on image view. There are actually a lot more techniques to load image from server. Hope this helps, Good Luck!

然后在图像视图上使用图像。实际上有很多技术可以从服务器加载图像。希望这有帮助,祝你好运!

#1


The method imageNamed: of UIImage you are using loads the local image, i.e. image that's contained in you app's bundle. In order to load image from the server, you have to use different techniques, like:

您正在使用的UIImage方法imageNamed:加载本地图像,即您应用程序包中包含的图像。要从服务器加载图像,您必须使用不同的技术,例如:

NSData *imageData = [NSData dataWithContentsOfURL:[NSURL urlWithString:{image_url}]]; 
UIImage *image = [UIImage imageWithData:imageData];

and then use image on image view. There are actually a lot more techniques to load image from server. Hope this helps, Good Luck!

然后在图像视图上使用图像。实际上有很多技术可以从服务器加载图像。希望这有帮助,祝你好运!