本文介绍了线程1:EXC_BAD_ACCESS(代码= 1,地址= 0x20)当subView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个奇怪的错误. Thread 1: EXC_BAD_ACCESS (code=1, address=0x20)当一个View子视图位于另一个视图上时.

I got a strange error. Thread 1: EXC_BAD_ACCESS (code=1, address=0x20)When a View subView on another view.

两个v iew object not nil.

我该如何解决这个问题.

How do I solve this issue.

修改:我正在使用VOIP实现视频聊天代码.

I am implementing a video chat code with VOIP.

当有来电时,接听电话后.我需要显示一个屏幕.此屏幕显示正常,并且其他UIElements按钮等.(包括按钮功能)一切正常,可以进行音频通话.

When an incoming call comes and after accept the call. I need to display a screen.This screen is showing fine and other UIElements button etc.. (including button functionalities) everything is working as expected for audio calls.

但是,在收到远程用户视频后的视频通话中,我试图将SubView转换为view.我可以查看远程用户屏幕一秒钟.突然崩溃(线程1:EXC_BAD_ACCESS(代码= 1,地址= 0x20)).

But, in video call after receive the remote user video I am trying to subView to a view . I could view the remote user screen for a second. suddenly get crashed (Thread 1: EXC_BAD_ACCESS (code=1, address=0x20)).

func session(_ session: QBRTCBaseSession, receivedRemoteVideoTrack videoTrack: QBRTCVideoTrack, fromUser userID: NSNumber) {

  if (session as! QBRTCSession).id == self.session?.id {

      let remoteView :QBRTCRemoteVideoView = QBRTCRemoteVideoView()
      remoteView.videoGravity = AVLayerVideoGravity.resizeAspect.rawValue
      remoteView.clipsToBounds = true
      remoteView.setVideoTrack(videoTrack)
      remoteView.tag = userID.intValue

      var frame = self.mainVideoView.bounds
      frame.origin.y = 0
      remoteView.frame = frame

      self.view.addSubview(remoteView)
     }
}

receivedRemoteVideoTrack函数是远程视频的委托方法.

Where receivedRemoteVideoTrack function is a delegate method for the remote video.

推荐答案

请记住,Metal仅适用于A7处理器或更高版本.我可以建议您强制使用OpenGLES而不是Metal绘图,现在,只需执行以下操作即可:

Keep in mind that Metal only available with A7 processors or higher. I can suggest you force OpenGLES drawings instead of Metal, for now, just do this:

QBRTCRemoteVideoView.preferMetal = NO

这篇关于线程1:EXC_BAD_ACCESS(代码= 1,地址= 0x20)当subView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 15:47