0

在 iOS 12 上将 RPSystemBroadcastPickerView 添加到我的自定义视图并将触摸事件发送到其内部按钮时,UI 被阻止并且无法响应任何触摸事件。

这是我的代码:当我收到通知时,我调用此方法来初始化我的自定义视图:

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

在 MyCustomView 类的 init 方法中,我创建 RPSystemBroadcoatPickerView 并将其添加到 MyCustomView:

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

但是当我运行我的项目时,有时 UI 被阻塞并且 MyCustomView 上的所有其他元素都无法触及。RPBroadcastPicker 崩溃日志将在设备日志中找到,但并非每次都在一般崩溃日志中。

我用过很多方法,例如直接将broadcastPicker添加到关键窗口,但无济于事。

任何人都可以帮助我吗?非常感谢。

4

1 回答 1

1
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];
    }
}
于 2020-04-08T15:12:53.910 回答