简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM