ios - Swift UIGestureRecognizer not working when added in initWithCoder -


i have custom uiview subclass ui designed in xib.

class myview: uiview {      override init(frame: cgrect) {         super.init(frame: frame)         loadview()         commoninit()     }      required init(coder adecoder: nscoder) {         super.init(coder: adecoder)         loadview()         commoninit()     }      func commoninit() {         let rightswiperecognizer = uiswipegesturerecognizer(target: self, action: selector("swipe"))         rightswiperecognizer.direction = .right         dayinfoview.addgesturerecognizer(rightswiperecognizer)     }      func swipe() {         println("swiped")     }          private func loadview() {         let mainbundle = nsbundle.mainbundle()         let views = mainbundle.loadnibnamed("myview", owner: self, options: nil)         let view = views.first as? uiview         addsubview(view!)     } } 

in storyboard, i've added view vc , ensured user interaction enabled on view. result: no swipe handling

in case add view manually works fine:

override func viewdidload() {     super.viewdidload()      let myview = myviewframe: cgrectmake(0, 300, 320, 200))     view.addsubview(myview) } 

what doing wrong?


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -