RXSwift 关于使用textFiled的时候onCompleted 什么时间执行的问题

来源:互联网 发布:windows如何切换到桌面 编辑:程序博客网 时间:2024/05/29 06:44

//
// hanjie.swift
// RXFunction
//
// Created by 王木木 on 16/11/2.
// Copyright © 2016年 王木木. All rights reserved.
//

import UIKit
import RxSwift

class hanhanhan: UIViewController {

let disposeBag = DisposeBag()var textF: UITextField?override func viewDidLoad() {    super.viewDidLoad()    // Do any additional setup after loading the view.    textF = hanTextF(frame: CGRectMake(50, 50, 200, 40))    textF!.tag = 100    view.addSubview(textF!)    textF!.backgroundColor = UIColor.brownColor()    textF!.rx_text.subscribe(onNext: {        print($0)        }, onError: nil, onCompleted: {            print("textFiled 释放")        }).addDisposableTo(disposeBag)}override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {    super.touchesBegan(touches, withEvent: event)    textF!.removeFromSuperview()    textF = nil}

}

class hanTextF: UITextField {
deinit {

    print("当前对象释放")}

}

/由上面来看是在textFiled销毁的时候执行/

0 0