@@ -37,6 +37,8 @@ class CustomizedTokenViewController: UIViewController, ICTokenFieldDelegate {
3737 override func loadView( ) {
3838 super. loadView ( )
3939 view. backgroundColor = UIColor . white
40+ textView. isEditable = false
41+ textView. isSelectable = false
4042 textView. text = " [ \n \n ] "
4143 textView. font = UIFont . preferredFont ( forTextStyle: . subheadline)
4244 textView. frame = view. bounds. insetBy ( dx: 10 , dy: 10 )
@@ -83,16 +85,29 @@ class CustomizedTokenViewController: UIViewController, ICTokenFieldDelegate {
8385 print ( #function)
8486 }
8587
86- func tokenField( _ tokenField: ICTokenField , didEnterText text: String ) {
87- print ( " Add: \" \( text) \" " )
88+ func tokenField( _ tokenField: ICTokenField , didChangeInputText text: String ) {
89+ print ( " Typing \" \( text) \" " )
90+ }
91+
92+ func tokenField( _ tokenField: ICTokenField , shouldCompleteText text: String ) -> Bool {
93+ print ( " Should add \" \( text) \" ? " )
94+ return text != " 42 "
95+ }
96+
97+ func tokenField( _ tokenField: ICTokenField , didCompleteText text: String ) {
98+ print ( " Added \" \( text) \" " )
8899 updateTexts ( )
89100 }
90101
91102 func tokenField( _ tokenField: ICTokenField , didDeleteText text: String , atIndex index: Int ) {
92- print ( " Delete: \" \( text) \" " )
103+ print ( " Deleted \" \( text) \" " )
93104 updateTexts ( )
94105 }
95106
107+ func tokenField( _ tokenField: ICTokenField , subsequentDelimiterForCompletedText text: String ) -> String {
108+ return " , "
109+ }
110+
96111 // MARK: - UIResponder Callbacks
97112
98113 @objc fileprivate func dismiss( _ sender: UIBarButtonItem ) {
0 commit comments