You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Zoom Video SDK iOS端批注无法显示问题求助

解决Zoom Video SDK批注不显示及工具属性重置问题

针对你遇到的批注无法显示、工具属性(类型/宽度/颜色)设置无效的问题,以下是针对性的修复方案:

核心问题定位

你当前调用createAnnotationHelper(nil)时传入了nil,导致批注助手无法绑定到共享视图的渲染层,后续的工具属性设置无法被正确应用,因此getToolType()、getToolWidth()返回默认值0,颜色也重置为黑色。

修复步骤

1. 绑定批注助手到共享视图

创建ZoomVideoSDKAnnotationHelper时,必须传入你正在共享的canvasView,而不是nil:

self.annoHelper = shareHelper.createAnnotationHelper(self.canvasView)

2. 调整工具属性设置顺序

SDK在启动批注时会重置默认属性,因此需要在startAnnotation()成功后再设置工具参数:

if let err = self.annoHelper?.startAnnotation(), err == .Errors_Success { 
    print("annotation started")
    // 批注启动成功后再配置工具属性
    self.annoHelper?.setToolColor(.systemRed)
    self.annoHelper?.setToolType(.pen)
    self.annoHelper?.setToolWidth(10)
    // 此时再打印属性就能看到正确值
    print(self.annoHelper?.getToolColor())
    print(self.annoHelper?.getToolWidth())
    print(self.annoHelper?.getToolType().rawValue)
}

3. 完善旧批注助手的清理逻辑

在创建新助手前,先停止旧批注并销毁,避免资源泄漏:

if let annoHelper = self.annoHelper {
    annoHelper.stopAnnotation()
    shareHelper.destroy(annoHelper)
    self.annoHelper = nil
}

4. 验证角色权限

确保当前用户是共享发起者:只有共享的发起者才能主动发起批注,观众需要发起者开启权限后才能操作(你已调用disableViewerAnnotation(false),此部分无需修改)。

修改后的完整代码片段

if let shareHelper = ZoomVideoSDK.shareInstance()?.getShareHelper() {
    let returnValue = shareHelper.startShare(with: self.canvasView)
    if returnValue == .Errors_Success {
        print("Sharing succeeded")
        print("shareHelper.isAnnotationFeatureSupport() = \(shareHelper.isAnnotationFeatureSupport())")
        
        let error1 = shareHelper.disableViewerAnnotation(false)
        print("shareHelper.enableViewerAnnotation == \(error1 == .Errors_Success)")
        print("shareHelper.isViewerAnnotationDisabled() = \(shareHelper.isViewerAnnotationDisabled())")
        
        // 清理旧批注助手
        if let annoHelper = self.annoHelper {
            annoHelper.stopAnnotation()
            shareHelper.destroy(annoHelper)
            self.annoHelper = nil
        }
        
        // 绑定共享视图创建批注助手
        self.annoHelper = shareHelper.createAnnotationHelper(self.canvasView)
        
        // 启动批注后再设置工具属性
        if let err = self.annoHelper?.startAnnotation(), err == .Errors_Success { 
            print("annotation started")
            self.annoHelper?.setToolColor(.systemRed)
            self.annoHelper?.setToolType(.pen)
            self.annoHelper?.setToolWidth(10)
            
            // 打印验证属性
            print("annohelper is :\(self.annoHelper!)")
            print(self.annoHelper?.getToolColor())
            print(self.annoHelper?.getToolWidth())
            print(self.annoHelper?.getToolType().rawValue)
        }
    } else {
        print("Sharing failed")
    }
}

内容的提问来源于stack exchange,提问作者Shahzaib Qureshi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 20:21:06