swift - My UIButton doesn't call the method targeted -


i don't know wrong #selector :

func iterate() {     scrollview.subviews[0].subviews[0].addsubview(arrowbutton)     arrowbutton.addtarget(self, action: #selector(self.pressbutton), for: .touchupinside)     self.view.bringsubview(tofront: arrowbutton) }  func pressbutton() {     print("pouet pouet pouet") }  override func viewdidload() {     super.viewdidload()     iterate() } 

(don't mind layout thing, i've removed constraints clarity's sake)

when press button, nothing printed.

i'm getting crazy #selector, how such important piece of development still using objc crap ?

edit : uibutton on top of layer, or @ least that's xcode debugging tool saying (the button in right bottom corner) = enter image description here

i think error in line (scrollview.subviews[0].subviews[0].addsubview(arrowbutton))

may button added under @ view jsut check

func iterate() {     scrollview.subviews[0].subviews[0].addsubview(arrowbutton)     arrowbutton.addtarget(self, action: #selector(self.pressbutton), for: .touchupinside) }  func pressbutton() {     print("pouet pouet pouet") }  override func viewdidload() {     super.viewdidload()     iterate() } 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -