[英]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.