Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Imageview根本没有加载_Ios_Objective C - Fatal编程技术网

Ios Imageview根本没有加载

Ios Imageview根本没有加载,ios,objective-c,Ios,Objective C,在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 URLWithStr

在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];


是否将UIImageView添加到当前视图?[self.view addSubview:\u showLogo];是的,将UIImageview添加到CurrentView这是一个很好的答案,我完全忘记了将其添加回视图中
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];