gpt4 book ai didi

ios - 如何在按钮操作上从 UIView 移动到 UIViewcontroller

转载 作者:搜寻专家 更新时间:2023-10-31 23:07:12 25 4
gpt4 key购买 nike

我在 UIView 上有一个按钮,我想在单击按钮时初始化一个 UIViewcontroller。我试图在单击按钮时显示另一个 ViewController 但出现错误:

reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key AboutUser.'

// Protocol in UIView Class
protocol TinderCardDelegate: NSObjectProtocol {
func didInfoButtonTapped()
}

class TinderCard: UIView {
@objc func info_Btn_Action(sender: UIButton) {
print("tap")
delegate?.didInfoButtonTapped()
}
}

// Code in UIViewController
class SwipeViewController: UIViewController
override func viewDidLoad() {
super.viewDidLoad()
}

func btninfoTapped() {
print("tappp")
let storyboard: UIStoryboard = UIStoryboard (name:
"UserProfileInfo", bundle: nil)

let vc: UserInfoViewController =
storyboard.instantiateViewController(withIdentifier:
"UserInfoViewController") as! UserInfoViewController

self.present(vc, animated: false, completion: nil)
}
}

extension SwipeViewController : TinderCardDelegate {

func didInfoButtonTapped() {
print("Button tapped ")
self.btninfoTapped()
}
}

最佳答案

原因:“[setValue:forUndefinedKey:]:此类与键 AboutUser 的键值编码不兼容。”

回复:可能是你从另一个 Controller 复制粘贴按钮请删除该类的操作并为该类提供操作

关于ios - 如何在按钮操作上从 UIView 移动到 UIViewcontroller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51134557/

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