How do I implement UIPageControl in Swift

后端 未结 4 1566
春和景丽
春和景丽 2021-02-02 10:30

Ok so I\'m struggling here and haven\'t been able to find a working solution. I\'ve been self learning Swift without Objective C experience (I know, I know).

In my app,

4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-02 10:48

    Delegates are just methods of a class, that can be palmed off to another class. These methods are usually callbacks.

    e.g. A callback for a TextField, when the user hits return, can be implemented in a Delegate. The delegate can be implemented in the ViewController class.

    Now when the user hits return the TextField Object will call the delegate method in the ViewController object. The great thing about this is, you can access all the variables and methods of the ViewController object from the delegated method. Otherwise you would need a handle to the ViewController object within the TextField object itself.

    Delegates are implemented as protocols, which are just interfaces. So if the ViewController implements the TextFieldDelegate protocol, all your textfield callbacks can be called from within the ViewController object.

    I hope this helps.

提交回复
热议问题