OTAnnotationAccelerator 1.0.0-beta4

OTAnnotationAccelerator 1.0.0-beta4

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布上次发布2020年11月

LucasHuangmarinasAlberto CintadoRoberto PerezAbdul Ajetunmobi 维护。



OpenTok Annotations Accelerator Pack for iOS

Tokbox is now known as Vonage

本文件描述了如何使用 OpenTok Annotations Accelerator Pack for iOS。

其中包含以下部分:

  • 先决条件:获取开始所需的一切清单。
  • 快速入门:一步一步的教程,帮助您开始使用 OpenTok Annotations Accelerator Pack for iOS 进行开发。
  • 探索代码:有关 API、类设计和配置的详细信息。

先决条件

为使用 OpenTok Annotations Accelerator Pack for iOS 进行开发做准备

  1. 获取 API 密钥会话 ID令牌。参见 获取 OpenTok 认证信息 获取重要信息。
  2. 安装 Xcode 5 或更高版本,并启用 ARC。
  3. 您的设备必须运行 iOS 8 或更高版本。

获取 OpenTok 认证信息

使用 OpenTok 的框架需要 Session ID、Token 和 API Key,您可以在 OpenTok 开发者仪表板 中获取这些值。对于生产部署,您必须使用以下任何一种 OpenTok 服务器 SDK 来生成 Session ID 和 Token 值。

快速入门

为了让您的应用程序快速启动,请按照以下步骤操作

  1. 添加库.
  2. 配置和构建应用程序.

添加库

要添加库并开始开发,请使用 CocoaPods 按以下步骤操作

  1. 在您的 pod 文件中添加以下行: pod 'OTAnnotationAccelerator'
  2. 在终端提示符下,导航到您的项目目录并输入 pod install。(有时,pod update 会很神奇)
  3. 使用新的 *.xcworkspace 文件重新打开您的项目。

注意:有关 CocoaPods 的更多信息,包括安装说明,请访问 CocoaPods 入门

配置和构建应用程序

配置示例应用程序代码。然后,构建并运行应用程序。

  1. 准备好 API Key、Session ID 和 Token 的值。见 获取 OpenTok 凭据

  2. AppDelegate.m 中将以下空字符串替换为相应的 API KeySession IDToken

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
        // Override point for customization after application launch.    
        [OTAcceleratorSession setOpenTokApiKey:@""
                                     sessionId:@""
                                         token:@""];
        return YES;
    }
  3. 使用 Xcode 在 iOS 模拟器或设备上构建并运行应用程序。

探索代码

关于开发此加速器包所使用的 API 的详细信息,请参阅 OpenTok iOS SDK 参考

注意: 本加速包仅收集用于内部TokBox的匿名使用数据。请勿修改或删除此示例应用程序中的任何日志代码。

类设计

以下类表示OpenTok注释加速包的软件设计。

描述
OTAnnotator 实现跨设备和平台远程注释的核心组件。
OTAnnotationScrollView 提供在屏幕的整个区域或指定区域注释的基本组件。
OTAnnotationToolbarView 一个方便的注释工具栏,供开发使用(可选)。作为替代,您可以使用 OTAnnotationScrollView 创建自己的工具栏。
OTFullScreenAnnotationViewController 一个方便的视图控制器,允许您立即注释整个屏幕。

注释功能

OTAnnotationScrollView 类是该示例中注释功能的支柱。

self.annotationView = [[OTAnnotationScrollView alloc] init];
self.annotationView.frame = <# desired frame #>;
[self.annotationView initializeToolbarView];
self.annotationView.toolbarView.frame = <# desired frame #>;

如果您想在整个屏幕或指定屏幕区域上注释

self.annotator = [[OTAnnotator alloc] init];
[self.annotator connectForReceivingAnnotationWithSize:<# desired size #>
                                    completionHandler:^(OTAnnotationSignal signal, NSError *error) {
                                        if (signal == OTAnnotationSessionDidConnect){
                                            self.annotator.annotationScrollView.frame = self.view.bounds;
                                            [self.view addSubview:self.annotator.annotationScrollView];
                                        }
                                    }];

self.annotator.dataReceivingHandler = ^(NSArray *data) {
    NSLog(@"%@", data);
};

如果您想在远程客户端的屏幕上注释

self.annotator = [[OTAnnotator alloc] init];
[self.annotator connectForSendingAnnotationWithSize:self.sharer.subscriberView.frame.size
                                completionHandler:^(OTAnnotationSignal signal, NSError *error) {
    
                                    if (signal == OTAnnotationSessionDidConnect){
        
                                        // configure annotation view
                                        self.annotator.annotationScrollView.frame = self.view.bounds;
                                        [self.view addSubview:self.annotator.annotationScrollView];

                                        // self.sharer.subscriberView is the screen shared from a remote client.
                                        // It does not make sense to `connectForSendingAnnotationWithSize` if you don't receive a screen sharing.
                                        [self.annotator.annotationScrollView addContentView:self.sharer.subscriberView];
        
                                        // configure annotation feature
                                        self.annotator.annotationScrollView.annotatable = YES;
                                        self.annotator.annotationScrollView.annotationView.currentAnnotatable = [OTAnnotationPath pathWithStrokeColor:[UIColor yellowColor]];
                                    }
                                }];

self.annotator.dataSendingHandler = ^(NSArray *data, NSError *error) {
    NSLog(@"%@", data);
};

第三方库

开发和贡献

有兴趣贡献?我们❤️合并请求!请参阅贡献指南

获取帮助

我们很高兴接收您的反馈。如果您对此项目有任何问题、评论或发现错误,请告诉我们!您可以在本存储库中

进一步阅读