在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类初始化方法中,我创建了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直接添加到key窗口中,但都无能为力。
有人能帮我吗?非常感谢。
发布于 2020-04-08 23:12:54
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];
}
}https://stackoverflow.com/questions/53665716
复制相似问题