1

Scenario:

  1. A host UIViewController containing assorted views, buttons; and navigation bar.
  2. User selects an item which presents a dependent UIViewController.
  3. User eventually dismisses the presented UIViewController.

Goal:
VoiceOver focus must return to the origin button within its container view (see red arrow below) versus default Navigation back arrow '<'.

Simulated Model
I've attempted to simplify the problem by creating a skeleton model of the situation.
The original code was written in Objective-C.
My skeleton is written in Swift.

Here's my simulated host UIViewController with its target button (origin) within its container view.
It's in VoiceOver mode running on my iPhone 6s Plus. It's about to display its presented VC:

[![enter image description here][1]][1]

Here's the presented UIViewController:

enter image description here

Here's the code snippet from the green HOST view controller:

class ThirdViewController: UIViewController {
    ...
    @IBOutlet var containerView: UIView!
    ...
    @IBOutlet var doSomethingButton: UIButton!

    // Toolbar Items:
    @IBOutlet var presentVCButton: UIBarButtonItem!
    ...

    override func viewDidLoad() {
        super.viewDidLoad()
        title = "Third ViewController"
        setupNotification()
        // Setup Accessibility:
        setupNotificationAccessibility()
        setupContainerAccessibility()
        setupDoSomethingAccessibility()
        setupToolbarItemsAccessibility()
    }
    ...

  // Present View Controller:
    @IBAction func displayPanelAction(_ sender: UIBarButtonItem) {
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        if let popupVC = storyboard.instantiateViewController(withIdentifier: "popupVC") as? PopUpViewController {
            popupVC.delegate = self
            present(popupVC, animated: true)
        }
    }
...



   // NOTE: If containerView.isAccessibilityElement = true,
    //       then containerView's member items are NOT ACCESSIBLE.

    fileprivate func setupContainerAccessibility() {
        containerView.isAccessibilityElement = false
        containerView.accessibilityLabel = "The Container"
        containerView.accessibilityHint = "Meredith thinks you're attractive!"
    }

    fileprivate func setupDoSomethingAccessibility() {
        doSomethingButton.accessibilityHint = "I actually don't do anything."
    }

Here's the code snippet from the Popup View Controller:

  // ------------------------------------------------
    // From 'X' Icon:
    @IBAction func exitAction(_ sender: UIButton) {
        guard let sender = delegate else { return }
        sender.accessibilityElements = [sender.doSomethingButton!]
        dismiss(animated: true, completion: nil)
    }

Two questions:

  1. How do I force the focus and have VoiceOver REPEAT the origin's label (in this case, the 'Do Something' button)?

  2. In the original case, the origin is a UIView with its tap gesture action versus a UIButton. Is it possible to force a focus on a UIView vs a UIButton of a different UIViewController?

Frederick C. Lee
  • 9,019
  • 17
  • 64
  • 105

0 Answers0