问题描述
- UIImageView不加载图片
-
使用ImageView从url加载图片失败:pdfView.hidden=NO; webView.hidden=NO; pictureImageView.hidden=NO; pdfView.backgroundColor=[UIColor clearColor]; doneButton = [[UIBarButtonItem alloc]initWithTitle:@" Done " style:UIBarButtonItemStyleBordered target:self action:@selector(doneButtonClick)]; self.navigationItem.leftBarButtonItem =doneButton; webView.backgroundColor=[UIColor clearColor]; NSLog(@"File Name is %@",fileName); NSLog(@"Enterning in the ImageSection"); NSString *ImageURL = fileName; NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:ImageURL]]; pictureImageView.image = [UIImage imageWithData:imageData];
同时,如果我要从本地读取也不显示:
pictureImageView.image=[UIImage imageNamed:@"starblue.png"];
请高手帮忙,谢谢
解决方案
先设置图片的框架,然后添加图片到pictureImageView中写下这行代码:
[self.view bringSubviewToFront:pictureImageView];
解决方案二:
用这段代码显示图片:
NSString *image=[NSString stringWithFormat:@"Your URL"] stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NSLog(@"%@",image);
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:image]];
Yourimageview=[UIImage imageWithData:imageData];
时间: 2024-10-31 15:17:45