从 "HTTPS" 类型的 url 加载图像并在 UIImageview 中显示
Load images from "HTTPS" type of url and display in UIImageview
我正在开发一个 iOS 应用程序,我在其中从服务器接收 "HTTPS" URL 图像。我现在无法从那些 URL 加载图像。我已经尝试了几个框架,如 AFNetworking、SDImageView 等。但是 none 能够从这些类型的 URL 中加载图像。
更新:
代码示例
[cell.imgVwPhoto setImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[arrayImages objectAtIndex:indexPath.row]]] placeholderImage:[UIImage imageNamed:@"placeholder-avatar"]
success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
[UIView transitionWithView:cell.imgVwPhoto
duration:0.2
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
cell.imgVwPhoto.image = image;
}
completion:NULL];
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error){
NSLog(@"Error");
}];
此处URL为HTTPS类型。
所以,这是行不通的。
如有帮助,将不胜感激。
试试这个
NSURL *url=[NSURL URLWithString:@"yourURL"];
NSData *data=[NSData dataWithContentsOfURL:url];
UIImage *aImage=[UIImage imageWithData:data];
这会起作用
NSData * imageData = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString: @"http://myurl/mypic.jpg"]];
UIImageView *imView = [[UIImageView alloc] initWithImage:[UIImage imageWithData: imageData]];
希望对您有所帮助。
通过修改我创建的webservice调用框架中的一些参数解决了问题。
所有这些更改都是根据我调用的服务器进行的。
谢谢
我正在开发一个 iOS 应用程序,我在其中从服务器接收 "HTTPS" URL 图像。我现在无法从那些 URL 加载图像。我已经尝试了几个框架,如 AFNetworking、SDImageView 等。但是 none 能够从这些类型的 URL 中加载图像。
更新:
代码示例
[cell.imgVwPhoto setImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[arrayImages objectAtIndex:indexPath.row]]] placeholderImage:[UIImage imageNamed:@"placeholder-avatar"]
success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
[UIView transitionWithView:cell.imgVwPhoto
duration:0.2
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
cell.imgVwPhoto.image = image;
}
completion:NULL];
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error){
NSLog(@"Error");
}];
此处URL为HTTPS类型。 所以,这是行不通的。
如有帮助,将不胜感激。
试试这个
NSURL *url=[NSURL URLWithString:@"yourURL"];
NSData *data=[NSData dataWithContentsOfURL:url];
UIImage *aImage=[UIImage imageWithData:data];
这会起作用
NSData * imageData = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString: @"http://myurl/mypic.jpg"]];
UIImageView *imView = [[UIImageView alloc] initWithImage:[UIImage imageWithData: imageData]];
希望对您有所帮助。
通过修改我创建的webservice调用框架中的一些参数解决了问题。 所有这些更改都是根据我调用的服务器进行的。
谢谢