我必须从休息服务url中检索图像。但我没有单独的图像URL(图像的路径)。我将它放在XML文件中。我解析了XML并将其存储在array.Now我无法理解如何从中检索图像.. 我的数组看起来像这样:
(
{
Image = "
9j/4AAQSkZJRgABAQAAAQABAAD//gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2NjIpLCBxdWFsaXR5ID0gODAK/9sAQwAGBAUGBQQGBgUGBwcGCAoQCgoJCQoUDg8MEB
cUGBgXFBYWGh0lHxobIxwWFiAsICMmJykqKRkfLTAtKDAlKCko/9sAQwEHBwcKCAoTCgoTKBoWGigoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgo/8AAEQgEKwZAAwEiAAIRAQMR
Af/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RV
VldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/aAAwDAQACEQMRAD8A9bDUu6qwenB6y
NCyGpQ1Vg9OD0XAsbqA9QlqAeaALOaXNQbqUPQInBpQagD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RupnNHNAEm6jdTOaM0ASbqN1R0ZoAk3UbqjzRmgCTdRuqPNGaAJN1G6o80ZoAk3UbqZmkzQBLuo3VFmlzQBJuo3VHmjNAEu6jdUWaM0AS7qN1RZo3UAS7qN1RbqTdQBNuo3VDuozQBNuo3VDmjdQBNuo3VDuo3Uhku6jdUO6jdQBNuo3VDupN1AE26jdUO6jdQBNuo3VDuo3Ug
//big array </Image>
}
)
我无法理解这是来自服务的格式(字节数组还是base64?)? 如何在tableViewCell中从中检索图像?
答案 0 :(得分:1)
如果这是base64字符串,则可以使用this将base64字符串解码为NSData,并且可以从NSData访问UIImage。
+ (NSData *)decodeBase64WithString:(NSString *)strBase64;
答案 1 :(得分:0)
此格式为base64,然后您应将此字符串解码为数据并获取图像。使用nsdata+ base64 class并在项目中导入这些类。
在代码中使用+ (NSData *)decodeBase64WithString:(NSString *)strBase64;
方法。像这样打电话
NSData *imageData = [NSData decodeBase64WithString:strBase64];
修改强>
NSString *yourBase64String = [yourDictionary valueForKey:@"Image"];
NSData *imageData = [NSData decodeBase64WithString:yourBase64String];
UIImage * image = [UIImage imageWithData:imageData];
答案 2 :(得分:0)
可能是因为对NSData + Base64文件进行了修改,但现在的方法是dataFromBase64String而不是decodeBase64WithString