我正在尝试向AVPlayerViewController
聊天气泡添加一个,以便收到的任何音频或视频消息都可以直接在聊天气泡中播放。我的UITableView
清单包含许多这样的气泡。但是当我尝试滚动表格视图时,应用程序会崩溃显示 -[AVPlayerViewController retain]: message sent to deallocated instance.
下面是我为AVPlayerViewController
每个聊天气泡添加对象的代码:-
_playerViewController = [[AVPlayerViewController alloc] init];
_playerViewController.player = [AVPlayer playerWithURL:url];
_playerViewController.view.frame = CGRectMake(10.0, 5.0, 190.0 , 90.0); // self.view.bounds;
_playerViewController.showsPlaybackControls = YES;
[_playerViewController.view setTranslatesAutoresizingMaskIntoConstraints:YES];
[_playerViewController .view setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin];
[cell.contentview addsubview:_playerViewController.view];
url 包含文件路径(音频/视频),我正在尝试将 _playerViewController
对象添加到UITableView
单元格的内容视图,但它会引发上述错误。谁能告诉我我应该做什么。