swift - 在表格 View 单元格中显示弹出窗口

标签 swift uitableview popup

我想在 Tableview 单元格 ViewController 中呈现一个弹出窗口。我想要这个,因为在 TableViewCell 中有一个按钮,按下时需要弹出。请帮我!如果我运行这个,我会收到错误:

InstagramClone.SignInViewController: 0x102e22b30 whose view is not in the window hierarchy!

@objc func kik (){
        if let Kik = user?.KikUsername {
            // Prepare the popup assets
            let title = "Kik Username"
            let message = "The Kik username from \(user?.username) is: \(Kik)."
            let image = UIImage(named: "kik-icon.jpg")

            // Create the dialog
            let popup = PopupDialog(title: title, message: message, image: image)

            // Create buttons
            let buttonOne = CancelButton(title: "Cancel") {
                print("You canceled")
            }

            // This button will not the dismiss the dialog
            let buttonTwo = DefaultButton(title: "Copy Kik Username to clipboard!", dismissOnTap: false) {
                UIPasteboard.general.string = Kik
            }
            popup.addButtons([buttonOne, buttonTwo])

            // Present dialog
            self.window?.rootViewController?.present(popup, animated: true, completion: nil)
        }

    }

最佳答案

我认为您只需将弹出窗口添加到主视图:

self.view.addSubview(popup)

关于swift - 在表格 View 单元格中显示弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49774081/

相关文章:

ios - 如何在 Xcode 中设置启动屏幕图像

swift - SwiftUI添加倒立面膜

ios - 在uitextview中消失键盘

javascript - 将 HTML 从原始文档复制到弹出窗口(使用 JQuery)

iOS(结构): Crashlytics crashing app on launch

ios - 重用单元格时,如何将 UISegmentedControl 的选定段保留在 UITableView 中?

ios - 如何在ios应用程序中正确弹出 View ?

ios - 使用核心数据和 TableView Controller 时从 UILabel 中删除空白属性

popup - 如何弹出一个最小化的 wxPython 窗口

javascript - 页面上弹出链接?