//
// 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销毁的时候执行/