How to detect when the RPSystemBroadcastPickerView is tapped

后端 未结 2 506
星月不相逢
星月不相逢 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.

    0 讨论(0)
  • 2021-01-14 05:56

    I did not find any callbacks for that, but you can create your transparent button, add it above the RPSystemBroadcastPickerView. When user will tap on your button you will be able to hide the keyboard and than transfer the action to the RPSystemBroadcastPickerView using the code:

    for subview in screenSharingProviderPickerView.subviews {
        if let button = subview as? UIButton {
             button.sendActions(for: UIControlEvents.allTouchEvents)
        }
    }
    
    0 讨论(0)
提交回复
热议问题