我正在开发一个swift 4项目,在其他功能中,我需要显示我的firebase /存储中的图像。
但是我已经试过了,但是我找不到正确的代码。
如果有人知道并想要帮助这位初学者,我将非常感激。
谢谢
发布于 2018-01-10 18:48:34
您可以使用以下代码片段获取图像URL:
Objective-C代码片段:
FIRStorageReference *storageRef = [[FIRStorage storage] reference];
FIRStorageReference *groupsRef = [storageRef child:[NSString stringWithFormat:@"%@/images/%@",@"Group",@"imageName"]];
[groupsRef downloadURLWithCompletion:^(NSURL * _Nullable URL, NSError * _Nullable error) {
}];
收到网址后,使用任何图像下载框架或NSUrlSession下载图像并在UIImageView中显示。
推荐图片下载工具:SDWebImage
希望这将有助于解决您的上述问题。根据您的要求将此Objective-C代码转换为Swift。
https://stackoverflow.com/questions/48185430
复制相似问题