ios - RxSwift not working with UIButton -


i working on rxswift , started creating few basic. have added new button rx_tap subscribe not working button action. below code, please let me know doing wrong

    let button = uibutton(frame: cgrect(x: 10, y: 66, width: 100, height: 21))     button.backgroundcolor = uicolor.redcolor()     button.settitle("login", forstate: uicontrolstate.normal)      let disposebag = disposebag()     button.rx_tap         .subscribe { [weak self] x in             self!.view.backgroundcolor = uicolor.redcolor()     }     .adddisposableto(disposebag)     self.view.addsubview(button) 

your subscription cancelled because of scope of disposebag. created, goes out of scope , deallocated. need retain bag somewhere. if using view controller or that, can create property there , assign that.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -