1

I try to call UIAccessibility’s registerGestureConflictWithZoom() but it has no effect. I’m running the code on an iPhone 12 with zoom gesture enabled. (Go to Settings > Accessibility > Zoom, then turn on Zoom.) But I’m not being presented with the choice of turning off Zoom when the app is run.

This, from the documentation, is my situation and what I would like to happen:

Use this function if your application uses multi-finger gestures that conflict with the gestures used by system Zoom (that is, three-finger gestures). When this is the case, the user is presented with the choice of turning off Zoom or continuing.

I have tried to call it from the app init:

import SwiftUI
import UIKit

@main
struct MultiTouchApp: App {
    
    init() {
        UIAccessibility.registerGestureConflictWithZoom()
    }
    
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

From my view init:

import Foundation
import UIKit

class CustomView: UIView {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        isMultipleTouchEnabled = true
        UIAccessibility.registerGestureConflictWithZoom()
    }
...

And also here in the view:

    override func didMoveToWindow() {
        UIAccessibility.registerGestureConflictWithZoom()
    }

I’ve also tried (in a separate project with UIKit App Delegate Life Cycle) to make the call from AppDelegates func application.

jblo
  • 111
  • 6

1 Answers1

1

It works if you make the call from touchesCancelled:

override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
        UIAccessibility.registerGestureConflictWithZoom()
        // other code
    }

When the start of a 3-finger gesture is detected touchesCancelled is called and a dialog is presented. It seems that this only happens once, the first time the app is run. For testing you can change the app’s bundle identifier and ios will treat it as a new app as mentioned here.

jblo
  • 111
  • 6