【问题标题】:Image not showing in first time objective c [closed]图像未在第一次目标 c 中显示 [关闭]
【发布时间】:2017-11-01 11:29:48
【问题描述】:

我正在处理目标 ci 在 imageview 中面临的问题。第一次没有显示图像,当我们转到下一个视图控制器并返回到前一个控制器时,图像正在显示。如果出现问题,请建议我。

这里是代码

dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
    dispatch_async(queue, ^{
        NSData * imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",UserDetail[@"profilePic"]]]];
        dispatch_async(dispatch_get_main_queue(), ^{
            UIImage *image = [UIImage imageWithData:imageData];
            profileImage.image = image;
            firstLetterlabel.hidden = true;
        });
    });

【问题讨论】:

  • 请出示相关代码!
  • 这是因为项目的第二个文件中的第 2 行(按字母顺序排序)。显然,我们不知道没有代码。这是一个异步问题吗?主线程有问题?
  • UIImageView *profileImage = [[UIImageView alloc]initWithFrame:CGRectMake(15, topbarView.frame.size.height-45, 35, 35)]; profileImage.layer.borderWidth = 1; profileImage.layer.borderColor=[[UIColor colorWithHexString:@"aeaeae"] CGColor]; profileImage.image = nil; [topbarView addSubview:profileImage];

标签: ios objective-c xcode uiimageview uiimage


【解决方案1】:

请在将 Image 设置为 imageview 之前尝试此代码

Yourimageview.clipsToBounds = true;
[Yourimageview layoutIfNeeded];

【讨论】:

  • 谢谢 Mitul 让我试试
猜你喜欢
  • 1970-01-01
  • 2013-06-09
  • 2021-11-15
  • 1970-01-01
  • 2014-09-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-14
相关资源
最近更新 更多