Dots of UIPageControl block taps

Originator:douglashill
Number:rdar://39775512 Date Originated:27-Apr-2018 12:18 am
Status:Open Resolved:
Product:iOS + SDK Product Version:11.3
Classification:UI/Usability Reproducible:Always
 
Summary:
The dots of a UIPageControl block taps from being handled by the page control. This leads to a poor user experience as the page control sometimes does not work when tapped.

Steps to Reproduce:
1. Open the attached sample project. It just puts a UIPageControl on screen and makes it big so the problem is easier to see.
2. Tap on a dot towards the right end.
3. Tap between the dots towards the right end.

Expected Results:
Page control should move from page 0 to 1 at step 2, then 1 to 2 at step 3. Wherever you tap on the page control, it should handle the event and change page.

Actual Results:
The page control does not change at step 2, only at step 3. This is because the subviews used for the dots have user interaction enabled and handle the touches, so they don’t reach the page control itself.

Version:
11.3

Notes:
This is easier with a mouse but it happens with touches too. With a normal size page control and finger touches you can’t tap with enough accuracy to reliably hit either the dots or the gaps so it affectivity becomes random whether the control works or not if touched around the dots.

Workaround is to subclass UIPageControl and override hit testing to return self instead of the dot subviews:

    class PageControl: UIPageControl {
        override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
            let hitView = super.hitTest(point, with: event)
            if hitView == nil {
                return nil
            } else {
                return self
            }
        }
    }

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!