首页 > 解决方案 > 将图像添加到操作表

问题描述

如何将表格视图的屏幕截图添加到 UIAlertController 中的第一个“动作”?我试着那样做

let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
let action = UIAlertAction(title: NSLocalizedString("Share routine", comment: ""), style: .default, handler: { _ in
})
action.setValue(image, forKey: "image")
actionSheet.addAction(action)
actionSheet.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .cancel, handler: nil))
UIApplication.topViewController()?.present(actionSheet, animated: true, completion: nil)

标签: swiftalert

解决方案


我试过你的代码,发现了一些错误

首先,代替图像使用

image.withRenderingMode(.alwaysOrigin)

如果您想将图像放置到某个位置,请使用 imageView


推荐阅读