gpt4 book ai didi

ios - Imageview 根本没有加载

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:17:53 25 4
gpt4 key购买 nike

我在 viewcontroller.h 中这样做。

@property( nonatomic, strong)IBOutlet UIImageView*showLogo;

在 viewcontroller.m 中,我正在这样做。

   NSString*path=@"http://www.stboston.com/wp-content/uploads/2012/08/iStock_000004791880_1.jpg";

NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data ];

_showLogo=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 500)];
_showLogo.image=img;

最佳答案

尝试将其直接加载到 _showLogo.image

_showLogo=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 500)];
_showLogo.image = [UIImage imageWithContentsOfURL:@"http://www.stboston.com/wp-content/uploads/2012/08/iStock_000004791880_1.jpg"];
[self.view addSubview:_showLogo];

NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.stboston.com/wp-content/uploads/2012/08/iStock_000004791880_1.jpg"]];
_showLogo.image = [UIImage imageWithData:imageData];
[self.view addSubview:_showLogo];

关于ios - Imageview 根本没有加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24767394/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com