Vyk*_*tas 3 photo uiimageview swift
我真的很需要帮助
我将图像保存到 DocumentDirectory 如何获取此图像并放入 UIImageView?
照片网址:
file:///Users/zoop/Library/Developer/CoreSimulator/Devices/3E9FA5C0-3III-41D3-A6D7-A25FF3424351/data/Containers/Data/Application/7C4D9316-5EB7-4A70-82DC-E76C654sEA20profile
尝试这样的事情:
let fileName = "profileImage.png"
let path = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first! + "/" + fileName
let image = UIImage(contentsOfFile: path)
Run Code Online (Sandbox Code Playgroud)
然后,你可以把image对UIImageView。
其他选项(如 Leo Dabus 在下面的评论中提到的):
let fileName = "profileImage.png"
let fileURL = NSURL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first!).URLByAppendingPathComponent(fileName)
if let imageData = NSData(contentsOfURL: fileURL) {
let image = UIImage(data: imageData) // Here you can attach image to UIImageView
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16012 次 |
| 最近记录: |