101 lines
3.5 KiB
Objective-C
101 lines
3.5 KiB
Objective-C
//
|
||
// GiGaFlingCommitVC.m
|
||
// GIGA
|
||
//
|
||
// Created by lianxiang on 2018/8/28.
|
||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||
//
|
||
|
||
#import "GiGaFlingCommitVC.h"
|
||
#import "GiGaFlyingCommitInputView.h"
|
||
#import "LXDanMuManager.h"
|
||
#import "GiGaCommentView.h"
|
||
#import "GiGaCommentModel.h"
|
||
#import "LXDanMuManagerConfig.h"
|
||
#import "IQKeyboardManager.h"
|
||
|
||
//弹幕控制器
|
||
@interface GiGaFlingCommitVC ()
|
||
@property (nonatomic,strong) GiGaFlyingCommitInputView *commitInputView;
|
||
|
||
@end
|
||
|
||
@implementation GiGaFlingCommitVC
|
||
|
||
- (void)viewDidLoad {
|
||
[super viewDidLoad];
|
||
// Do any additional setup after loading the view.
|
||
NC_ADD_TARGET_NAME_OBJECT(self, @selector(maskTimeEnd), kUserNoti_MASKEND, nil);
|
||
[self.view addSubview: self.commitInputView];
|
||
self.commitInputView.SendCommentHandler = ^(NSString *content) {
|
||
GILog(@"发送->:%@",content);
|
||
};
|
||
[[LXDanMuManager shareInstance] createDanmuWithTrackSpeedArray:@[@1.00,@1.00,@3.00,@4.00] centerY:self.view.frame.size.height / 4 trackWidth:self.view.frame.size.width showInView:self.view];
|
||
[[LXDanMuManager shareInstance] start];
|
||
|
||
[NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(danmuAction) userInfo:nil repeats:YES];
|
||
|
||
|
||
}
|
||
|
||
-(void)danmuAction{
|
||
|
||
[self showFlyingCommit];
|
||
}
|
||
|
||
- (GiGaFlyingCommitInputView *)commitInputView{
|
||
|
||
if (!_commitInputView) {
|
||
// _commitInputView = [[GiGaFlyingCommitInputView alloc] initWithFrame:CGRectMake(0,self.view.frame.size.height - 60 , KMainW, 60)];
|
||
_commitInputView = [[GiGaFlyingCommitInputView alloc] initWithFrame:self.view.bounds];
|
||
[_commitInputView setPalceholderText:@"请输入弹幕"];
|
||
}
|
||
return _commitInputView;
|
||
}
|
||
-(void)viewWillAppear:(BOOL)animated{
|
||
[super viewWillAppear:animated];
|
||
[IQKeyboardManager sharedManager].enable = NO;
|
||
[[IQKeyboardManager sharedManager] setEnableAutoToolbar:NO];
|
||
}
|
||
|
||
- (void)viewWillDisappear:(BOOL)animated{
|
||
[super viewWillDisappear:animated];
|
||
[IQKeyboardManager sharedManager].enable = YES;
|
||
[[IQKeyboardManager sharedManager] setEnableAutoToolbar:YES];
|
||
}
|
||
|
||
-(void)showFlyingCommit{
|
||
NSArray *classArray = @[@"GiGaCommentView",@"GiGaCommentView"];
|
||
NSArray *nameArray = @[@"mc子龙",@"小明",@"赵四",@"狂小狗",@"葬爱"];
|
||
NSArray *msgArray = @[@"老铁666",@"主播,多少礼物给卡黄啊?",@"文明观球,大家有秩序排队观看,不要着急",@"主播,我报警啦",@"就是个萨比,还扮滴酷酷滴aaaaa"];
|
||
NSArray *avatarArray = @[@"home_login_qq_color",@"home_login_qq_color",@"home_login_qq_color",@"home_login_qq_color",@"home_login_qq_color"];
|
||
int classRandomIndex = arc4random() % 2;
|
||
int nameRandomIndex = arc4random() % 5;
|
||
int msgRandomIndex = arc4random() % 5;
|
||
int avatarRandomIndex = arc4random() % 5;
|
||
|
||
GiGaCommentModel *model = [[GiGaCommentModel alloc]init];
|
||
model.userName = nameArray[nameRandomIndex];
|
||
model.msg = msgArray[msgRandomIndex];
|
||
model.userAvatar = avatarArray[avatarRandomIndex];
|
||
GiGaCommentView *customView = [[NSClassFromString(classArray[classRandomIndex]) alloc] initWithMsgModel:model height:TRACK_HEIGHT];
|
||
[[LXDanMuManager shareInstance] appendDanMuWithCustomView:customView toTrackIndex:-1];
|
||
}
|
||
|
||
-(void)maskTimeEnd{
|
||
|
||
[[LXDanMuManager shareInstance] destory];
|
||
[self dismissViewControllerAnimated:YES completion:nil];
|
||
}
|
||
|
||
- (void)didReceiveMemoryWarning {
|
||
[super didReceiveMemoryWarning];
|
||
// Dispose of any resources that can be recreated.
|
||
}
|
||
|
||
-(void)dealloc{
|
||
NC_REMOVE_NAME(self, kUserNoti_MASKEND, nil);
|
||
}
|
||
|
||
@end
|