为什么在可视化调试中看不到inputAccessoryView?

时间:2018-06-30 14:32:28

标签: ios xcode debugging inputaccessoryview

我在这里附加了模拟器屏幕截图和视图调试窗口。 screenshot from xcode view debuggersimulator screenshot

如您所见,inputAccessoryView在模拟器中可见,但在视觉调试中不可见,并且不明白为什么,请提供帮助:)

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
    }
}

1 个答案:

答案 0 :(得分:5)

inputAccessoryView在另一个名为UITextEffectsWindow的窗口中,要使其显示在视图调试器中,您必须从调试导航器选项卡中选择该窗口或该窗口中的任何子项