问题描述
所以,我很确定我非常接近让它发挥作用。我认为可能只有 .delegate =
行不起作用。
首先是协议
protocol beever1: class {
func beever2()
}
现在在 UITableViewCell1:
var delegate1: beever1?
长按时,下面的代码在一个函数中运行(我无法通过 uicontextmenuconfiguration 返回,因为 uicontextmenuconfiguration 中有一个数据库检查 - 这就是我呈现而不是返回的原因)。
if let delegate3 = self.delegate1{
delegate3.beever2()
}
然后在长按上需要启动的UITableViewController1
extension UITableViewController1: beever1 {
func beever2() {
let image3 = UIImage(named:"green.png")
if let unwrappedImage1 = image3 {
self.present(ImagePreviewController(image:unwrappedImage1),animated: true,completion: nil)
}
}
}
// I kNow this part works because I Could successfull ypresent it on another VC
override func tableView(_ tableView: UITableView,cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if let cell = tableView.dequeueReusableCell(withIdentifier: "cell",for: indexPath) as? UITableViewCell1 {
**cell.delegate1 = self**.
// probably where error is but I think it makes sense as is: I am sending delegate info from cell to this UITableViewContoller bacause I want the UITableViewContoller to launch,right?///
return cell
}
return UITableViewCell()
}
更新:
我现在想我明白为什么它不显示了,但不知道如何解决它。长按时 UITableViewController1 未加载到屏幕上。第三个 TableViewController 上的 UITableViewCell1 被加载到屏幕上。然后长按 UITableViewController1 需要出现。所以因为 UITableViewController1 没有加载,只需要长按加载,cellForRowAt 函数不会自动读取
我认为我可以做什么,但不知道如何编码。 Option1) 在 UITableViewCell1 我需要以某种方式将委托编码为 self.delegate1 = UITableViewController1,但目前这不起作用
选项2是UITableViewCell1所在的第三个TableViewController。在它的 cellForRowAt 我可以说:cell.delegate1 = UITableViewController1。但这目前也不起作用
你们都同意我的评估吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)