0

我必须从休息服务 url 中检索图像。但我没有单独的图像 URL(图像的路径)。我在 XML 文件中获取它。我解析了 XML 并将其存储在一个数组中。现在我不明白如何从中检索图像。我的数组如下所示:

   (
    {
    Image = "

    9j/4AAQSkZJRgABAQAAAQABAAD//gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2NjIpLCBxdWFsaXR5ID0gODAK/9sAQwAGBAUGBQQGBgUGBwcGCAoQCgoJCQoUDg8MEB
    cUGBgXFBYWGh0lHxobIxwWFiAsICMmJykqKRkfLTAtKDAlKCko/9sAQwEHBwcKCAoTCgoTKBoWGigoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgo/8AAEQgEKwZAAwEiAAIRAQMR
    Af/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RV
    VldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/aAAwDAQACEQMRAD8A9bDUu6qwenB6y
NCyGpQ1Vg9OD0XAsbqA9QlqAeaALO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QA/dS7qZzRzQA/dRupnNHNAEm6jdTOaM0ASbqN1R0ZoAk3UbqjzRmgCTdRuqPNGaAJN1G6o80ZoAk3UbqZmkzQBLuo3VFmlzQBJuo3VHmjNAEu6jdUWaM0AS7qN1RZo3UAS7qN1RbqTdQBNuo3VDuozQBNuo3VDmjdQBNuo3VDuo3Uhku6jdUO6jdQBNuo3VDupN1AE26jdUO6jdQBNuo3VDuo3Ug
         //big array </Image>
        }
        )

我不明白这是来自服务的什么格式(字节数组或base64?)?如何在 tableViewCell 中从中检索图像?

4

3 回答 3

1

If this is base64 string then You can decode base64 string to NSData using this and you can access UIImage from NSData.

+ (NSData *)decodeBase64WithString:(NSString *)strBase64;
于 2012-11-27T05:32:59.003 回答
0

This format is base64 then you should decode this string into data and get image. Use nsdata+ base64 class and import those class in your project.

Use + (NSData *)decodeBase64WithString:(NSString *)strBase64; method in your code. call like this

 NSData *imageData = [NSData decodeBase64WithString:strBase64];

Edit:

 NSString *yourBase64String = [yourDictionary valueForKey:@"Image"];
 NSData *imageData = [NSData decodeBase64WithString:yourBase64String];
 UIImage * image = [UIImage imageWithData:imageData];
于 2012-11-27T05:47:00.790 回答
0

可能是因为对 NSData+Base64 文件进行了修改,但现在的方法是 dataFromBase64String 而不是 decodeBase64WithString

于 2013-11-29T00:38:23.113 回答