4_5-带货场景-互动
更新時間:2023-04-17 15:27:57
1 功能概述
互動功能包括公告、簽到、抽獎、答題卡和問卷功能。該功能是在PLVECWatchRoomViewController中實現,整合7_6-核心common-互動中的PLVInteractView來實現的功能。
2 使用演示
帶貨場景互動功能只需在頁面中加入PLVInteractView,並呼叫其初始化方法,即可完成整合。
在接收到主播端發起的抽獎等功能時,互動應用介面將會自動顯示。
範例程式碼如下
/// 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];
}
