# 4\_5-带货场景-互动

* [1 功能概述](#_1-功能概述)
* [2 使用演示](#_2-使用演示)

#### 1 功能概述

互动功能包括公告、签到、抽奖、答题卡、和问卷功能。该功能是在`PLVECWatchRoomViewController`中实现，集成[7\_6-核心common-互动](https://git.polyv.net/help-center/document-center/-/blob/master/live/ios/7_6-%E6%A0%B8%E5%BF%83common-%E4%BA%92%E5%8A%A8/README.md)中`PLVInteractView`来实现的功能。

#### 2 使用演示

带货场景互动功能只需要在 页面 中加入`PLVInteractView`，并调用其初始化方法，即可完成集成。

在接收到主播端发起的抽奖等功能时，互动应用界面将会自动显示。

示例代码如下

```objective-c
/// PLVECWatchRoomViewController.m

@property (nonatomic, strong) PLVInteractView *interactView; // 互动

- (void)setupModule{
    PLVRoomData *roomData = [PLVRoomDataManager sharedManager].roomData;
    if (roomData.videoType == PLVChannelVideoType_Live) {
				/// 直播
				/// 注册互动通知
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationForOpenBulletin:) name:PLVLEChatroomOpenBulletinNotification object:nil];
        
    } else if (roomData.videoType == PLVChannelVideoType_Playback){
    		/// 回放
    }
}

- (void)setupUI{
    if (roomData.videoType == PLVChannelVideoType_Live) {
        /// 直播
        
        /// 互动
        [self.view addSubview:self.interactView];

        /// 互动配置
        self.interactView.frame = self.view.bounds;
        self.interactView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        [self.interactView loadOnlineInteract];
        
    } else if (roomData.videoType == PLVChannelVideoType_Playback){
        /// 回放
    }
}

- (PLVInteractView *)interactView{
    PLVChannelVideoType videoType = [PLVRoomDataManager sharedManager].roomData.videoType;
    if (!_interactView && videoType == PLVChannelVideoType_Live) {
        _interactView = [[PLVInteractView alloc] init];
        _interactView.frame = self.view.bounds;
        _interactView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        [_interactView loadOnlineInteract];
    }
    return _interactView;
}

- (void)notificationForOpenBulletin:(NSNotification *)notif {
    [self.interactView openLastBulletin];
}

```
