我想将图像从imageview保存到特定文件夹图像来自Sqlserver.并且我想在sqlite中保存它的链接以便进一步处理我已经编写了这个代码,它在文档目录中保存图像但每次路径都不同.请告诉我该怎么办 ?
let imageData = UIImagePNGRepresentation(imageee.image!)!
let docDir = try! FileManager.default.url(for: .picturesDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
let imageURL = docDir.appendingPathComponent("tmp.png")
try! imageData.write(to: imageURL)
print(imageURL.path)
let newImage = UIImage(contentsOfFile: imageURL.path)!
//aftersave.image = newImage
aftersave.image = newImage
Run Code Online (Sandbox Code Playgroud) 我在uitableview中遇到问题每当我选择一个单元格第4个没有单元格自动被选中...我厌倦了这个问题有人请帮助这里是我的didselectrowfunc ..
func tableView(_ tableView:UITableView,didSelectRowAt indexPath:IndexPath){
////////////////添加复选框////////////////////////
if tableView.cellForRow(at: indexPath)?.accessoryType == UITableViewCellAccessoryType.checkmark
{
if selectedDisease.count > 0
{
let no = selectedDisease.index(of: finall[indexPath.row])
selectedDisease.remove(at: no!)
tableView.cellForRow(at: indexPath)?.accessoryType = UITableViewCellAccessoryType.none
print(selectedDisease)
}
else
{
selectedDisease = [""]
}
}
else
{
if selectedDisease.contains("")
{
selectedDisease.removeAll()
var name = finall[indexPath.row]
selectedDisease.append(name)
tableView.cellForRow(at: indexPath)?.accessoryType = UITableViewCellAccessoryType.checkmark
print(selectedDisease)
}
else
{
tableView.cellForRow(at: indexPath)?.accessoryType = UITableViewCellAccessoryType.checkmark
selectedDisease.append(finall[indexPath.row])
//selectedDisease = [finall[indexPath.row]]
print(selectedDisease)
}
}
}
Run Code Online (Sandbox Code Playgroud)
///////// CellForRowAt ///////////////
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> …Run Code Online (Sandbox Code Playgroud)