How to access an IBOutlet from another class

前端 未结 3 1649
Happy的楠姐
Happy的楠姐 2020-12-05 15:07

I want to know how to access an @IBOutlet declared in a class from another class

for example, I have a class named myfirstview

class MyFirstView: UIV         


        
3条回答
  •  误落风尘
    2020-12-05 15:39

    Problem is here :

    var lblred : UILabel! = UILabel()
    

    You creating a new label here. That breaking your IBOutlet connection. You only need

    @IBOutlet var lblred : UILabel!
    

提交回复
热议问题