gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 11:35:59 25 4
gpt4 key购买 nike

我想在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com