简体   繁体   English

如何在自定义单元格中显示UIImage

[英]How to display an UIImage in a custom cell

I am trying to display an Logo image in my custom cell, from amazon Amazon S3 bucket though StackMob but its not showing. 我试图在我的自定义单元中通过StackMob从亚马逊Amazon S3存储桶中显示徽标图像,但未显示。 if l paste the direct url path to the image it works, how do i get around this. 如果我将直接url路径粘贴到它可以工作的图像,我该如何解决。

NSManagedObject *object = [self.fetchedResultsController objectAtIndexPath:indexPath];

 CGRect imageFrame = CGRectMake(2, 2, 67, 67);

 self.customImage = [[UIImageView alloc] initWithFrame:imageFrame];

    NSURL* imageURL = [NSURL URLWithString:[object valueForKey:@"restoLogo"]];

    NSData *data = [[NSData alloc] initWithContentsOfURL:imageURL];

  UIImage *tmpImage = [[UIImage alloc] initWithData:data];

  self.customImage.image = tmpImage;
   [cell.contentView addSubview:self.customImage];

the image is at this path [object valueForKey:@"restoLogo"] now returns the s3 url for the data. 图像位于此路径[object valueForKey:@“ restoLogo”]现在返回数据的s3 url。

If you are not using NSString's instance method 如果您不使用NSString的实例方法

stringByAddingPercentEscapesUsingEncoding:

that could be the issue. 那可能是问题。

For example 例如

NSString *escapedString = [imgURLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

Then turn it into a URL and continue on your way. 然后将其转换为URL,然后继续操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在单元格中显示UIImage数组? - How can I display UIImage array in cell? 如何将UIImage正确锚定到位于自定义单元格的UIView中? - How to anchor a UIImage correctly into UIView located in a Custom Cell? 如何显示静态自定义单元格 - How to display Static Custom Cell 自定义UITableView单元格,UIImage从边界到边界 - Custom UITableView cell with UIImage from border to border 如何在TableView中显示两个自定义单元格? - How to Display two Custom Cell in TableView? 在Swift中使用自定义类在数组中显示UIImage - Display UIImage within an array with custom class in Swift 当UITapGestureRecognizer在prepareForSegue中点击并捕获其中的UIImage时,如何获取自定义表格视图单元格的索引路径 - How to get the indexpath of a custom table view cell when an UIImage inside of it is tapped and captured by UITapGestureRecognizer in prepareForSegue 如何在自定义单元格中使UIImage的宽度等于视图的宽度和比例高度 - How to make UIImage width be equal to view's width and proportional height inside a custom cell 如何在UIImage顶部显示标签? - How to display label on top of UIImage? 如何在iOS中的UITableView中显示UIImage - How to display UIImage within UITableView in IOS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM