Search code examples
iosswifteventsuipageviewcontrolleruipagecontrol

IBOutlet or event for UIPageControl not in the StoryBoard


I'm starting to program for Ios with Swift.

Although I have a doubt,

How can I do an IBOutlet or an event to control when I touch the right or left of the UIPageControl?

It's not in the StoryBoard, it's a variable.

I attach image.

https://i.sstatic.net/L7Dv1.png

Thanks in advance.


Solution

  • Add an event for value Changed on the page control and handle the action.

    self.pageControl.addTarget(self, action: #selector(pageControlValueChanged), for: .valueChanged)

    @objc func pageControlValueChanged(sender: UIPageControl) {

    }