gpt4 book ai didi

iphone - 按钮触发另一个 View

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

现在我有这个:

 lazy var Button: UIButton = {
let tb = UIButton()
tb.backgroundColor = UIColor.yellowColor()
tb.clipsToBounds = true
tb.layer.cornerRadius = 39
tb.addTarget(self, action: #selector(showButton), forControlEvents: .TouchUpInside)
tb.setBackgroundImage(UIImage(named: "buttonMenu"), forState: UIControlState.Normal)
return tb
}()

如何让按钮将我带到另一个 View 或执行其他操作(例如打开相机)?

PS:showButton 函数实际上并没有做任何事情。

最佳答案

所以你有

tb.addTarget(self, action: #selector(showButton), forControlEvents: .TouchUpInside)

但你需要

tb.addTarget(self, action: #selector(className.showButton), forControlEvents: .TouchUpInside)

func showButton(sender:UIButton) {
//Code

}

关于iphone - 按钮触发另一个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38287707/

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