-->

How to detect when the RPSystemBroadcastPickerView

2019-07-14 19:25发布

问题:

I am using RPSystemBroadcastPickerView to start a system-wide screen recording from my app. The RPSystemBroadcastPickerView is completely autonomous in starting the recording and everything, which I guess makes sense - only user can start the screen recording by explicitly tapping the button.

I need to know when the RPSystemBroadcastPickerView is tapped. Right now the UI is showing keyboard, which I want to keep showing (it is a chat app). However, the form showing the list of broadcast extensions to pick one is being shown under the keyboard. See following image:

This effectively prevents the user to start the broadcast. If I knew when the user tapped RPSystemBroadcastPickerView, I could manually hide the keyboard at that moment. Any suggestions?

回答1:

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