How to detect when the RPSystemBroadcastPickerView is tapped

后端 未结 2 533
星月不相逢
星月不相逢 2021-01-14 05:25

I am using RPSystemBroadcastPickerView to start a system-wide screen recording from my app. The RPSystemBroadcastPickerView is completely autonomou

2条回答
  •  日久生厌
    2021-01-14 05:52

    I found similar solution to accepted answer, but you don't need to create transparent button.
    I just add additional target-action pair to the picker button dispatch table, with #selector which will be fired, when button is pressed.

    /// picker is an instance of RPSystemBroadcastPickerView
    for subviews in picker.subviews {
        if let button = subviews as? UIButton {
            button.addTarget(self, action: #selector(pickerAction), for: .touchUpInside)
        }
    }
    
    /// You can also accept _ sender: UIButton as parameter, if you need to.
    @objc func pickerAction() {
        /// called when user press on RPSystemBroadcastPickerView
    }
    

    Note: Keep in mind that, if Apple change hierarchy of this view in the future, you probably need to update application as well.

提交回复
热议问题