UIButton touch up inside event hook up in coding phase?

后端 未结 1 1372
生来不讨喜
生来不讨喜 2021-02-14 03:40

I create a UIButton in coding phase and never use Interface Builder so how can I call touch up inside event to hook up with any method in coding phase?

1条回答
  •  孤街浪徒
    2021-02-14 04:13

    [button addTarget:self action:@selector(BtnPressed:) forControlEvents:UIControlEventTouchUpInside];
    

    Swift 3:

    button.addTarget(self, action: #selector(ViewControllerName.BtnPressed), for: .touchUpInside)
    

    0 讨论(0)
提交回复
热议问题