需要双击单元格以模态呈现 VC
Need to double tap on cell to present modally VC
我正在生成 table 个单元格。
cell2 = settingsTableView.dequeueReusableCell(withIdentifier: "ModuleCell", for: indexPath) as! ModuleCell
看起来不错,单元格有 tag = 2000
。
在 override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
中,我正在检查标签结束 if tag == 2000
我想呈现模态视图。我就是这样做的
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let modalView = storyboard.instantiateViewController(withIdentifier: "ModalView")
present(modalView, animated: true, completion: nil)
然后在 modalView 中我有一个按钮应该关闭 modalView,正如预期的那样。
@IBAction func saveAndClosePopup(_ sender: UIButton) {
UserDefaults.standard.removeObject(forKey: "ActiveCantachoOptions")
UserDefaults.standard.set(Modules.activeCantachoOptions, forKey: "ActiveCantachoOptions")
self.dismiss(animated: true, completion: nil)
}
但是,当我想立即再次呈现modalView时,有时还可以,但有时我需要在单元格上点击两次,该单元格应该显示modalView。第一次命中后,我在 1 秒或 30 秒内再次命中单元格没有区别。 modalView 将出现在第二个之后。是什么原因?
试试这个
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let modalView = storyboard.instantiateViewController(withIdentifier: "ModalView")
self.present(modalView, animated: true) {
tableView.deselectRow(at: indexPath, animated: false)
}
}
我正在生成 table 个单元格。
cell2 = settingsTableView.dequeueReusableCell(withIdentifier: "ModuleCell", for: indexPath) as! ModuleCell
看起来不错,单元格有 tag = 2000
。
在 override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
中,我正在检查标签结束 if tag == 2000
我想呈现模态视图。我就是这样做的
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let modalView = storyboard.instantiateViewController(withIdentifier: "ModalView")
present(modalView, animated: true, completion: nil)
然后在 modalView 中我有一个按钮应该关闭 modalView,正如预期的那样。
@IBAction func saveAndClosePopup(_ sender: UIButton) {
UserDefaults.standard.removeObject(forKey: "ActiveCantachoOptions")
UserDefaults.standard.set(Modules.activeCantachoOptions, forKey: "ActiveCantachoOptions")
self.dismiss(animated: true, completion: nil)
}
但是,当我想立即再次呈现modalView时,有时还可以,但有时我需要在单元格上点击两次,该单元格应该显示modalView。第一次命中后,我在 1 秒或 30 秒内再次命中单元格没有区别。 modalView 将出现在第二个之后。是什么原因?
试试这个
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let modalView = storyboard.instantiateViewController(withIdentifier: "ModalView")
self.present(modalView, animated: true) {
tableView.deselectRow(at: indexPath, animated: false)
}
}