ios - UIButton not responding to touches -


i've following view:

enter image description here

the way build up

uiviewcontroller --> uiview (bottom square) --> uiviewcontroller (is loaded in bottom square)

button presses within in uiviewcontroller not being triggered. see button animate when press down in simulator.

also when add following tap handler programmatically round uiimageview in uiviewcontroller responds:

func handletap(sender: uitapgesturerecognizer? = nil) {         print("tappable")     }  let tap = uitapgesturerecognizer(target: self, action: #selector(neighbourhoodviewcontroller.handletap(_:))) userpopupview.userimageview.userinteractionenabled = true userpopupview.userimageview.addgesturerecognizer(tap) 

how can catch actions upon these buttons? isn't working:

@ibaction func test(sender: anyobject) {         print("test")     } 

the line connected uibutton in interface builder btw:

enter image description here

i found solution. had add viewcontroller view:

self.popupview.addsubview(userpopupview.view) 

when should have been:

self.addchildviewcontroller(userpopupview) self.popupview.addsubview(userpopupview.view) userpopupview.didmovetoparentviewcontroller(self) 

now works!


Comments