iosxcodedebugginginputaccessoryview

Why inputAccessoryView is not visible in visual debugging?


I attached here the simulator screenshot and the view debugging window. screenshot from xcode view debugger and simulator screenshot

As you can see inputAccessoryView is visible in simulator but not in the visual debugging and don't understand why, please help :)

The code for the inputAccessoryView:

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        view.backgroundColor = .blue
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    override var inputAccessoryView: UIView? {
        let v = UIView.init(frame: CGRect.init(x: 0, y: 0, width: view.frame.size.width, height: 60))
        v.backgroundColor = .red
        let label = UILabel()
        label.textAlignment = .center
        label.translatesAutoresizingMaskIntoConstraints = false
        v.addSubview(label)
        label.text = "inputAccessoryView"
        label.widthAnchor.constraint(equalToConstant: 250).isActive = true
        label.centerXAnchor.constraint(equalTo: v.centerXAnchor).isActive = true
        label.centerYAnchor.constraint(equalTo: v.centerYAnchor).isActive = true
        return v
    }

    override var canBecomeFirstResponder: Bool {
        return true
    }
}

Solution

  • inputAccessoryView is on another window called UITextEffectsWindow and for it to show up in the view debugger you have to select that window or any sub item in the window from the debug navigator tab