【发布时间】:2016-08-02 21:16:31
【问题描述】:
我无法解决这个问题 - 它应该很简单。
我有:
ShowAVPlayer 方法
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
}
【问题讨论】:
-
为什么要向 contentOverlayView 添加按钮?只需将其添加到查看。即 [self.avmovieplayer.view addSubview : btn];
标签: ios objective-c uibutton