How do you connect the “delegate” outlet of a UITextView to a class that implements UITextViewDelegate protocol?

后端 未结 3 1394
耶瑟儿~
耶瑟儿~ 2021-01-05 03:38

How do you connect the \"delegate\" outlet of a UITextView to a class that implements UITextViewDelegate protocol?

I can\'t seem to find an example in the docs

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-05 04:27

    To wire up a delegate in Interface Builder:

    (1) Drag an appropriate controller into the nibs main window and set the class of the controller to the class of your delegate. For example, if you have an NSObject subclass called "MyDelegateClass", drag an Object controller over and set it's class to "MyDelegateClass".

    (2) In the connections inspector for the UITextView, control-click on delegate and connect that to the controller created in step (1).

    That's it.

提交回复
热议问题