gpt4 book ai didi

ios - contentOverlayView 上的按钮没有响应

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:01:14 27 4
gpt4 key购买 nike

我无法解决这个问题 - 它应该很简单。

我有:

显示播放器方法

AVPlayerItem *video = [[AVPlayerItem alloc] initWithURL:url];
AVQueuePlayer *queue = [[AVQueuePlayer alloc] initWithItems:@[video]];
video = [[AVPlayerItem alloc] initWithURL:url];
[queue insertItem:video afterItem:nil];
AVPlayer *player = [AVPlayer playerWithURL:url];
self.avmovieplayer = [AVPlayerViewController new];

我想在叠加层上添加一个按钮 - 但该按钮没有响应:

UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btn setTitle:@"Do stuff" forState:UIControlStateNormal];
btn.frame = CGRectMake(0, 330, 320, 40);
[btn addTarget:self action:@selector(DoSpeech:) forControlEvents:UIControlEventTouchUpInside];
[btn setUserInteractionEnabled:true];
[self.avmovieplayer.contentOverlayView addSubview:btn];

这是我的 DoSpeech,它永远不会被调用:

- (void) DoSpeech:(UIButton *)button {

//DoSpeech

}

最佳答案

试试这个,

[btn setUserInteractionEnabled:YES];
[self.avmovieplayer.contentOverlayView bringSubviewToFront:btn];

希望对您有所帮助。

关于ios - contentOverlayView 上的按钮没有响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36570232/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com