When add RPSystemBroadcastPickerView to my custom view and send event to it internal button, UI cannot response

1.9k views Asked by At

When adding RPSystemBroadcastPickerView to my custom view on iOS 12, and send touch event to its internal button, UI blocked and cannot response any touch event.

Here is my code: When I receive a notification, I call this method to init my custom view:

- (void)presentMyCustomView
{
    MyCustomView *myCustomView = [[[[UIApplication sharedApplication] delegate] window] viewWithTag:kMyCustomViewTag];
    if (!myCustomView)
    {
        myCustomView = [[MyCustomView alloc] init];
        myCustomView.tag = kMyCustomViewTag;
        [[[[UIApplication sharedApplication] delegate] window] addSubview:myCustomView];
        [myCustomView release];
    }
}

In MyCustomView class's init method, I create RPSystemBroadcoatPickerView and add it to MyCustomView:

RPSystemBroadcastPickerView *broadcastPicker = [[RPSystemBroadcastPickerView alloc] initWithFrame:CGRectMake(0, 0, 100.f, 100.f)];
broadcastPicker.preferredExtension = @"xxxxx";
self.broadcastPicker = broadcastPicker;
[self addSubview:broadcastPicker];
[broadcastPicker release];

But when I run my project, sometimes UI blocked and all other elements on MyCustomView cannot be touched. RPBroadcastPicker crash log will be found in device logs but not everytime general crash log.

I have used many methods, for example, add broadcastPicker to the key window directly, but cannot help.

Anyone can help me? Many thanks.

1

There are 1 answers

0
Mike Glukhov On
if (@available(iOS 12.0, *)) {
    RPSystemBroadcastPickerView *pickerView = [RPSystemBroadcastPickerView new];
    pickerView.preferredExtension = @"com.apple.sharescreen";
    SEL buttonPressed = NSSelectorFromString(@"buttonPressed:");
    if ([pickerView respondsToSelector:buttonPressed]) {
        [pickerView performSelector:buttonPressed withObject:nil];
    }
}