我正在尝试做一些非常基本的事情,我有一个分配了YouTubePlayerView类的插座,一旦加载了ID,它就会崩溃。 为什么会崩溃? 我检查了插座连接是否正确,调试器显示videoId是否正确定义。
代码:
onChange(data) {
this.props.dispatch({ type: 'SetSelectedBoards', data });
}
<MultiSelect
items={ this.props.boards }
label="Boards"
selectedItems={ this.props.selectedBoards }
onChange={ e => this.onChange(e) } />
}
答案 0 :(得分:0)
好吧,我仍然不确定导致崩溃的原因,我相信它与框架有关,并且在Storyboard中添加的UIView类型(并通过身份检查器将其设置为YouTubePlayerView)导致崩溃在尝试加载videoId时。
解决方法是以编程方式添加播放器。我在故事板中使用了一个简单的视图,以便在初始化时为我的播放器提供框架。但是否则以编程方式顺利运行。 代码:
@IBOutlet weak var viewForPlayer: UIView!
override func viewDidLoad() {
super.viewDidLoad()
let frameForPlayer = viewForPlayer.frame
let player = YouTubePlayerView(frame: frameForPlayer)
player.loadVideoID(InstructionsVideoId)
player.play()
self.view.addSubview(player)
}