rx-cocoa

Bind two UIview fram/Position using Rxswift

一个人想着一个人 提交于 2019-12-04 08:26:24
I want to change view2 position automatically when view1 position will change and bind the both view position using Rxswift. I try to observe view frame/position using this view.rx.observe(CGRect.self,"frame") .subscribe(onNext: { print($0 ?? (0,0)) }) it print frame on init time but when change view position using constraints self.constraintHorizontalCenterView.constant = 1000 it print nothing means this code not observe view position... Is there any way to observe continuously view position or bind view position? from apple ' frame ' // animatable. do not use frame if view is transformed

Reload Tableview using RxSwift

☆樱花仙子☆ 提交于 2019-12-03 20:24:34
I am using RxSwift for tableview. I need to reload my table each time after getting data from api but I'm failed to do this. I couldn't find any solution for that. Can anybody help? I have an array of places obtain from response of an Api.I have used this code in view did load, but its is not being called when array is updated. Mehreen I have found the issue. My array was not being getting updated correctly. I did the following changes. Declare dataSource variable of ModelClass: let dataSource = Variable<[SearchResult]>([]) Bind it with the table view right now it is empty: dataSource

Observing UITextField.editing with RxSwift

↘锁芯ラ 提交于 2019-12-03 05:58:21
I want to observe the property UITextfield.editing . I'm using this code: self.money.rx_observe(Bool.self, "editing").subscribeNext { (value) in print("") }.addDisposableTo(disposeBag) But in the process of running, it's only performed once. How do I solve this,please solidcell Don't observe the editing property, because it's not just a stored property. It's defined as: public var editing: Bool { get } So you don't know how UIKit is actually getting that value. Instead, use rx.controlEvent and specify the control events you're interested in, like so: textField.rx.controlEvent([.editingDidBegin

RxSwift/RxCocoa: prevent UITextField from having more than … characters

随声附和 提交于 2019-11-30 18:04:52
I would like to have a UITextField configured with RxSwift/RxCocoa so that it only contains up to ... characters. I do not want to use the UITextFieldDelegate for this but would love to achieve this with RxSwift/RxCocoa. Is there a way to do this? Sure: textField.rx.controlEvent(.editingChanged).subscribe(onNext: { [unowned self] in if let text = self.textField.text { self.textField.text = String(text.prefix(40)) } }).disposed(by: disposeBag) In this example, the textfield is limited to 40 characters. Edit: Keeping the previous value when the limit is reached. textField.rx.text.orEmpty .scan("

RxSwift and isSelected property on UIButton

梦想与她 提交于 2019-11-30 05:47:53
I have three buttons and I want them to be selected only one at a time: and: etc... My approach is this: class MyController: UIViewController { @IBOutlet var buttonOne: UIButton! @IBOutlet var buttonTwo: UIButton! @IBOutlet var buttonThree: UIButton! var buttonOneIsSelected = Variable(true) var buttonTwoIsSelected = Variable(false) var buttonThreeIsSelected = Variable(false) override func viewDidLoad() { super.viewDidLoad() buttonOne.isSelected = true buttonOneIsSelected.asDriver() .drive(buttonOne.rx.isSelected) .disposed(by: disposeBag) buttonTwoIsSelected.asDriver() .drive(buttonTwo.rx

RxSwift and isSelected property on UIButton

时光总嘲笑我的痴心妄想 提交于 2019-11-29 03:59:02
问题 I have three buttons and I want them to be selected only one at a time: and: etc... My approach is this: class MyController: UIViewController { @IBOutlet var buttonOne: UIButton! @IBOutlet var buttonTwo: UIButton! @IBOutlet var buttonThree: UIButton! var buttonOneIsSelected = Variable(true) var buttonTwoIsSelected = Variable(false) var buttonThreeIsSelected = Variable(false) override func viewDidLoad() { super.viewDidLoad() buttonOne.isSelected = true buttonOneIsSelected.asDriver() .drive