2 ooomiao oOOMIAO 于 2013.06.28 16:29 提问

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

请高手帮忙,谢谢

2个回答

loFataMer
loFataMer   2013.06.28 16:58
已采纳

先设置图片的框架,然后添加图片到pictureImageView中写下这行代码:

        [self.view bringSubviewToFront:pictureImageView];
lianlianbushell
lianlianbushell   2013.06.28 17:00

用这段代码显示图片:

  NSString *image=[NSString stringWithFormat:@"Your URL"] stringByReplacingOccurrencesOfString:@" " withString:@"%20"];

            NSLog(@"%@",image);
            NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:image]];

            Yourimageview=[UIImage imageWithData:imageData];
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!