uiview - On a programmatic view, my button can't be clicked -
i have uiview leads uiview. have userinteraction set true. button shows, button not when clicked. added println statement make sure wasn't code ran in function. wrong view, or how button , function connected.
i using swift.
this code. in snipits, won't see viewdidload method:
let initiallaunchcontroller = uiview() let teachingscreen = uiview() learntoplaybutton.settitle("click here learn how play.", forstate: .normal) learntoplaybutton.settitlecolor(uicolor.whitecolor(), forstate: .normal) learntoplaybutton.titlelabel.font = uifont(name: "helveticaneue-ultralight", size: 35) learntoplaybutton.titlelabel.textalignment = .center learntoplaybutton.addtarget(self, action: "learntoplaypage:", forcontrolevents: .touchupinside) learntoplaybutton.frame = cgrectmake(37, 70, 500, 200) initiallaunchcontroller.backgroundcolor = uicolor.whitecolor() teachingscreen.backgroundcolor = uicolor.whitecolor() initiallaunchcontroller.userinteractionenabled = true teachingscreen.userinteractionenabled = true func learntoplaypage(sender: uibutton!) { //switch view teach learn play println("debugging..") let imageviewinsidefunc = uiimageview(image: background) self.teachingscreen.addsubview(imageviewinsidefunc) self.teachingscreen.addsubview(titletoteachtoplaylabel) self.teachingscreen.addsubview(teachtoplaylabel) self.teachingscreen.addsubview(suregetstartedbutton) self.initiallaunchcontroller.addsubview(teachingscreen) }
you should wrap action parameter selector initializer:
learntoplaybutton.addtarget(self, action: selector("learntoplaypage"), forcontrolevents: uicontrolevents.touchupinside)
Comments
Post a Comment