Create a UIImage from string data

前端 未结 1 798
一个人的身影
一个人的身影 2021-01-27 15:36

I am trying to populate an UIImageView with image data taken from a webservice. Below is what I am trying to do and it does not populate the image at all. The UIImageView is b

相关标签:
1条回答
  • 2021-01-27 16:01

    I was able to use a method as follows

    - (UIImage *)decodeBase64ToImage:(NSString *)strEncodeData {
    NSData *data = [[NSData alloc]initWithBase64EncodedString:strEncodeData options:NSDataBase64DecodingIgnoreUnknownCharacters];
    return [UIImage imageWithData:data];
    

    }

    And pass it my base64 string from the webservice call like this:

    UIImage *image = [self decodeBase64ToImage:imageData];
    
    [Photo setImage:image];
    
    0 讨论(0)
提交回复
热议问题