I’ve overridden the accessibilityPerformMagicTap() operate in a UIViewController subclass to detect the magic faucet gesture for that view controller. Nevertheless, when triggering the magic faucet, the operate is just not being referred to as.
How can I correctly observe the magic faucet gesture?
I additionally tried including this operate in AppDelegate, however it didn’t obtain a callback both.
Word: I haven’t used the accessibilityPerformMagicTap() operate anyplace else in my undertaking.
Under i’ve hooked up the pattern code.
class SecondaryVC : UIViewController{
non-public var actionButton : UIButton = {
let button = UIButton(kind: .system)
button.backgroundColor = .systemGreen
button.setTitle("Add", for: .regular)
button.layer.cornerRadius = 8
return button
}()
override func viewDidLoad(){
tremendous.viewDidLoad()
view.backgroundColor = .systemTeal
//Suggestion from StackOverFlow (Cannot entry subviews)
view.isAccessibilityElement = true
view.accessibilityTraits = [.button]
view.accessibilityLabel = "Secondary View targeted"
tabBarItem = UITabBarItem(title: "Secondary", picture: UIImage(systemName: "sq."), selectedImage: UIImage(systemName: "sq..fill"))
addSubViews()
}
override class func accessibilityPerformMagicTap() -> Bool {
print(">>>> SecondaryVC accessibilityPerformMagicTap")
return true
}
override class func accessibilityPerformEscape() -> Bool {
print(">>>> secodaryVC EscapeAction")
return true
}
non-public func addSubViews(){
view.addSubview(actionButton)
actionButton.translatesAutoresizingMaskIntoConstraints = false
actionButton.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor,fixed: 16).isActive = true
actionButton.leadingAnchor.constraint(equalTo: view.leadingAnchor,fixed: 16).isActive = true
actionButton.trailingAnchor.constraint(equalTo: view.trailingAnchor,fixed: -16).isActive = true
}
}