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) =
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
Post a Comment