作者herbacin (herbacin)
看板MacDev
標題[問題] 關於取得元件問題
時間Tue Jan 10 18:52:07 2017
請問一下各位大大
假設我在ViewController 加入了兩個 UITextView
var textView1 = UIView(frame: CGRect(x:0, y:0, width:100, height:100))
var textView2 = UIView(frame: CGRect(x:100, y:100, width:100, height:100))
textView1.delegate = self
textView2.delegate = self
self.view.addSubView(textView1)
self.view.addSubView(textView2)
func textViewDidBeginEditing(_ textView: UITextView) {
//問題 :請問這邊要如何判斷是 textView1在進行編輯
還是 textView2在進行編輯呢?
}
麻煩各位非常感謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 60.250.132.73
※ 文章網址: https://www.ptt.cc/bbs/MacDev/M.1484045530.A.163.html
推 Esvent: 把兩個textView作為成員變數存起來 跟參數比較 01/10 18:55
→ darktt: if textView == self.textView1 01/10 18:56
→ darktt: 或是採用view的tag來辨識 01/10 18:57
→ herbacin: 非常感謝兩位 01/10 19:04