Commit e6eefa72 authored by lujunye's avatar lujunye

修复使用方法

parent 487a7347
...@@ -10,7 +10,7 @@ import UIKit ...@@ -10,7 +10,7 @@ import UIKit
@objc protocol TitleAndTFCellDelegate { @objc protocol TitleAndTFCellDelegate {
@objc optional func textFieldContent(content:String,cell:TitleAndTFCell) @objc optional func textFieldContent(content:String,cell:TitleAndTFCell)
} }
class TitleAndTFCell: UITableViewCell,UITextFieldDelegate { class TitleAndTFCell: UITableViewCell {
@IBOutlet weak var line: UIView! @IBOutlet weak var line: UIView!
var delegate:TitleAndTFCellDelegate? var delegate:TitleAndTFCellDelegate?
@IBOutlet weak var textTF: UITextField! @IBOutlet weak var textTF: UITextField!
...@@ -18,13 +18,14 @@ class TitleAndTFCell: UITableViewCell,UITextFieldDelegate { ...@@ -18,13 +18,14 @@ class TitleAndTFCell: UITableViewCell,UITextFieldDelegate {
override func awakeFromNib() { override func awakeFromNib() {
super.awakeFromNib() super.awakeFromNib()
self.selectionStyle = .none self.selectionStyle = .none
textTF.delegate = self textTF.addTarget(self, action: #selector(textChange(textField:)), for: .allEditingEvents)
} }
func textFieldDidEndEditing(_ textField: UITextField) { @objc func textChange(textField:UITextField){
delegate?.textFieldContent?(content: textField.text!, cell: self) delegate?.textFieldContent?(content: textField.text!, cell: self)
} }
override func setSelected(_ selected: Bool, animated: Bool) { override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated) super.setSelected(selected, animated: animated)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment