YBLivePreview.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. //
  2. // YBLivePreview.m
  3. // YBVideo
  4. //
  5. // Created by YB007 on 2019/11/29.
  6. // Copyright © 2019 cat. All rights reserved.
  7. //
  8. #import "YBLivePreview.h"
  9. #import "ZFModalTransitionAnimator.h"
  10. #import "startLiveClassVC.h"
  11. #import "YBShareView.h"
  12. @interface YBLivePreview()<UITextViewDelegate,TZImagePickerControllerDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate> {
  13. UIImageView *loactionImgView;
  14. UILabel *locationLabel;
  15. UIButton *preThumbBtn; //上传封面按钮
  16. UILabel *thumbLabel; //上传封面状态的label
  17. UITextView *liveTitleTextView;
  18. UILabel *textPlaceholdLabel;
  19. NSMutableArray *preShareBtnArray; //分享按钮数组
  20. NSString *selectShareName; //选择分享的名称
  21. UILabel *liveClassLabel;
  22. NSString *liveClassID;
  23. NSArray *_funcTypeArr;
  24. UIButton *openGoodsCar;
  25. }
  26. @property (nonatomic, strong) ZFModalTransitionAnimator *animator;
  27. @end
  28. @implementation YBLivePreview
  29. - (instancetype)initWithFrame:(CGRect)frame {
  30. self = [super initWithFrame:frame];
  31. if (self) {
  32. liveClassID = @"-99999999";
  33. [self createUI];
  34. }
  35. return self;
  36. }
  37. -(void)createUI {
  38. _inputTitleStr = @"";
  39. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hidePreTextView)];
  40. [self addGestureRecognizer:tap];
  41. loactionImgView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 42+statusbarHeight, 22, 22)];
  42. loactionImgView.image = [UIImage imageNamed:@"pre_location"];
  43. [self addSubview:loactionImgView];
  44. UIView *locationLabelView = [[UIView alloc]init];
  45. locationLabelView.backgroundColor = RGB_COLOR(@"#000000", 0.3);
  46. locationLabelView.layer.cornerRadius = 8;
  47. locationLabelView.layer.masksToBounds = YES;
  48. [self addSubview:locationLabelView];
  49. [locationLabelView mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.centerY.equalTo(loactionImgView);
  51. make.left.equalTo(loactionImgView.mas_right).offset(-8);
  52. make.height.mas_equalTo(22);
  53. }];
  54. locationLabel = [[UILabel alloc]init];
  55. locationLabel.font = [UIFont systemFontOfSize:11];
  56. locationLabel.textColor = [UIColor whiteColor];
  57. locationLabel.text = [cityDefault getLocationCity];
  58. [locationLabelView addSubview:locationLabel];
  59. [locationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.centerY.equalTo(locationLabelView);
  61. make.height.mas_equalTo(22);
  62. make.left.equalTo(locationLabelView).offset(10);
  63. make.right.equalTo(locationLabelView).offset(-10);
  64. }];
  65. [self insertSubview:locationLabelView belowSubview:loactionImgView];
  66. UIButton *locationSwitchBtn = [UIButton buttonWithType:0];
  67. [locationSwitchBtn addTarget:self action:@selector(locationSwitchBtnClick) forControlEvents:UIControlEventTouchUpInside];
  68. [self addSubview:locationSwitchBtn];
  69. [locationSwitchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.left.top.height.equalTo(loactionImgView);
  71. make.right.equalTo(locationLabelView);
  72. }];
  73. //定位不展示做隐藏处理
  74. loactionImgView.hidden = locationLabelView.hidden = locationSwitchBtn.hidden = YES;
  75. // UIButton *switchBtn = [UIButton buttonWithType:0];
  76. // [switchBtn setImage:[UIImage imageNamed:@"pre_camer"] forState:0];
  77. // [switchBtn addTarget:self action:@selector(rotateCamera) forControlEvents:UIControlEventTouchUpInside];
  78. // [self addSubview:switchBtn];
  79. // [switchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  80. // //make.left.equalTo(locationLabelView.mas_right).offset(10);
  81. // make.left.equalTo(self.mas_left).offset(10);
  82. // make.centerY.equalTo(locationSwitchBtn);
  83. // make.height.width.equalTo(loactionImgView.mas_height);
  84. // }];
  85. _locationSwitch = YES;
  86. UIButton *preCloseBtn = [UIButton buttonWithType:0];
  87. preCloseBtn.frame = CGRectMake(16, loactionImgView.top, loactionImgView.height, loactionImgView.height);
  88. [preCloseBtn setImage:[UIImage imageNamed:@"pub_back"] forState:0];
  89. [preCloseBtn addTarget:self action:@selector(doClosePreView) forControlEvents:UIControlEventTouchUpInside];
  90. [self addSubview:preCloseBtn];
  91. //
  92. // UIView *preMiddleView = [[UIView alloc]initWithFrame:CGRectMake(10, _window_height/2-(_window_width-20)*38/71, _window_width-20, (_window_width-20)*38/71)];
  93. UIView *preMiddleView = [[UIView alloc]initWithFrame:CGRectMake(10, _window_height/3-(_window_width-20)*0.31, _window_width-20, (_window_width-20)*0.31)];
  94. preMiddleView.backgroundColor = RGB_COLOR(@"#0000000", 0.3);
  95. preMiddleView.layer.cornerRadius = 5;
  96. [self addSubview:preMiddleView];
  97. preThumbBtn = [UIButton buttonWithType:0];
  98. // preThumbBtn.frame = CGRectMake(10, preMiddleView.height*2/19, preMiddleView.height*10/19, preMiddleView.height*10/19);
  99. preThumbBtn.frame = CGRectMake(10, 10, preMiddleView.height-20, preMiddleView.height-20);
  100. [preThumbBtn setImage:[UIImage imageNamed:@"pre_uploadThumb"] forState:0];
  101. [preThumbBtn addTarget:self action:@selector(doUploadPicture) forControlEvents:UIControlEventTouchUpInside];
  102. preThumbBtn.layer.cornerRadius = 5.0;
  103. preThumbBtn.layer.masksToBounds = YES;
  104. [preMiddleView addSubview:preThumbBtn];
  105. thumbLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, preThumbBtn.height*0.75, preThumbBtn.width, preThumbBtn.height/4)];
  106. thumbLabel.textColor = RGB_COLOR(@"#c8c8c8", 1);
  107. thumbLabel.textAlignment = NSTextAlignmentCenter;
  108. thumbLabel.text = YZMsg(@"直播封面");
  109. thumbLabel.font = [UIFont systemFontOfSize:13];
  110. [preThumbBtn addSubview:thumbLabel];
  111. // UIButton *liveClassBtn = [UIButton buttonWithType:0];
  112. // liveClassBtn.frame = CGRectMake(preMiddleView.width-80, 0, 70, 30);
  113. // [liveClassBtn addTarget:self action:@selector(showAllClassView) forControlEvents:UIControlEventTouchUpInside];
  114. // [preMiddleView addSubview:liveClassBtn];
  115. // liveClassLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 55, 30)];
  116. // liveClassLabel.text = YZMsg(@"频道");
  117. // liveClassLabel.textAlignment = NSTextAlignmentRight;
  118. // liveClassLabel.textColor = [UIColor whiteColor];
  119. // liveClassLabel.font = [UIFont systemFontOfSize:14];
  120. // [liveClassBtn addSubview:liveClassLabel];
  121. //
  122. // UIImageView *rightImgView = [[UIImageView alloc]initWithFrame:CGRectMake(liveClassLabel.right+1, 8, 14, 14)];
  123. // rightImgView.image = [UIImage imageNamed:@"pre_right"];
  124. // rightImgView.userInteractionEnabled = YES;
  125. // [liveClassBtn addSubview:rightImgView];
  126. UILabel *preTitlelabel = [[UILabel alloc]initWithFrame:CGRectMake(preThumbBtn.right+10, preThumbBtn.top, 100, preThumbBtn.height/4)];
  127. preTitlelabel.font = [UIFont systemFontOfSize:13];
  128. preTitlelabel.textColor = RGB_COLOR(@"#c7c7c7", 1);
  129. preTitlelabel.text = YZMsg(@"直播标题");
  130. [preMiddleView addSubview:preTitlelabel];
  131. liveTitleTextView = [[UITextView alloc]initWithFrame:CGRectMake(preTitlelabel.left, preTitlelabel.bottom, preMiddleView.width-10-preThumbBtn.right, preThumbBtn.height*0.75)];
  132. liveTitleTextView.delegate = self;
  133. liveTitleTextView.font = [UIFont systemFontOfSize:20];
  134. liveTitleTextView.textColor = [UIColor whiteColor];
  135. liveTitleTextView.backgroundColor = [UIColor clearColor];
  136. [preMiddleView addSubview:liveTitleTextView];
  137. textPlaceholdLabel = [[UILabel alloc]initWithFrame:CGRectMake(3, 10, liveTitleTextView.width, 22)];
  138. textPlaceholdLabel.font = [UIFont systemFontOfSize:20];
  139. textPlaceholdLabel.textColor = RGB_COLOR(@"#c9c9c9", 1);
  140. textPlaceholdLabel.text = YZMsg(@"给直播写个标题吧");
  141. [liveTitleTextView addSubview:textPlaceholdLabel];
  142. UIView *liveclassView = [[UIView alloc]initWithFrame:CGRectMake(10, preMiddleView.bottom+10, _window_width-20, 40)];
  143. liveclassView.backgroundColor = RGB_COLOR(@"#0000000", 0.3);
  144. liveclassView.layer.cornerRadius = 5;
  145. [self addSubview:liveclassView];
  146. UIImageView *classImg = [[UIImageView alloc]init];
  147. classImg.frame = CGRectMake(10, 13, 20, 14);
  148. classImg.image = [UIImage imageNamed:@"live_class"];
  149. classImg.contentMode = UIViewContentModeScaleAspectFit;
  150. [liveclassView addSubview:classImg];
  151. UIButton *liveClassBtn = [UIButton buttonWithType:0];
  152. liveClassBtn.frame = CGRectMake(classImg.right+5, 5, liveclassView.width-classImg.right-30, 30);
  153. [liveClassBtn addTarget:self action:@selector(showAllClassView) forControlEvents:UIControlEventTouchUpInside];
  154. [liveclassView addSubview:liveClassBtn];
  155. liveClassLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, liveClassBtn.width, 30)];
  156. liveClassLabel.text = YZMsg(@"选择直播频道");
  157. liveClassLabel.textAlignment = NSTextAlignmentLeft;
  158. liveClassLabel.textColor = [UIColor whiteColor];
  159. liveClassLabel.font = [UIFont systemFontOfSize:14];
  160. [liveClassBtn addSubview:liveClassLabel];
  161. UIImageView *rightImgView = [[UIImageView alloc]initWithFrame:CGRectMake(liveClassBtn.width-20, 8, 14, 14)];
  162. rightImgView.image = [UIImage imageNamed:@"pre_right"];
  163. rightImgView.userInteractionEnabled = YES;
  164. [liveClassBtn addSubview:rightImgView];
  165. /// 禁用提示
  166. UILabel *banAlertL = [[UILabel alloc]init];
  167. banAlertL.textColor = Pink_Cor;
  168. banAlertL.font = SYS_Font(15);
  169. banAlertL.numberOfLines = 0;
  170. banAlertL.text = [YBPower getBanLiveMsg];
  171. [self addSubview:banAlertL];
  172. [banAlertL mas_makeConstraints:^(MASConstraintMaker *make) {
  173. make.top.equalTo(liveclassView.mas_bottom).offset(10);
  174. make.width.equalTo(preMiddleView.mas_width).offset(-20);
  175. make.centerX.equalTo(preMiddleView);
  176. }];
  177. banAlertL.hidden = ![YBPower getBanLiveStatus];
  178. //开播按钮
  179. UIButton *startLiveBtn = [UIButton buttonWithType:0];
  180. startLiveBtn.size = CGSizeMake(_window_width*0.8,40);
  181. startLiveBtn.center = CGPointMake(_window_width*0.5, _window_height*0.8);
  182. startLiveBtn.layer.cornerRadius = 20.0;
  183. startLiveBtn.layer.masksToBounds = YES;
  184. [startLiveBtn setBackgroundColor:Pink_Cor];
  185. [startLiveBtn addTarget:self action:@selector(clickStartLiveBtn:) forControlEvents:UIControlEventTouchUpInside];
  186. [startLiveBtn setTitle:YZMsg(@"开始直播") forState:0];
  187. startLiveBtn.titleLabel.font = [UIFont systemFontOfSize:15];
  188. [self addSubview:startLiveBtn];
  189. NSArray *functionArr;
  190. NSArray *functionImgArr;
  191. NSString *_isshop = minstr([YBPower getIsShop]);
  192. if ([_isshop isEqual:@"1"]) {
  193. functionArr = @[YZMsg(@"购物车"),YZMsg(@"翻转"),YZMsg(@"美颜"),YZMsg(@"分享"),YZMsg(@"上热门")];
  194. functionImgArr = @[@"pre_fun_shop",@"pre_fun_camera",@"pre_fun_meiyan",@"pre_fun_share",@"pre_fun_uphot"];
  195. _funcTypeArr = @[@(FunctionType_shop),@(FunctionType_camera),@(FunctionType_meiyan),@(FunctionType_share),@(FunctionType_upHot)];
  196. }else{
  197. functionArr = @[YZMsg(@"翻转"),YZMsg(@"美颜"),YZMsg(@"分享"),YZMsg(@"上热门")];
  198. functionImgArr = @[@"pre_fun_camera",@"pre_fun_meiyan",@"pre_fun_share",@"pre_fun_uphot"];
  199. _funcTypeArr = @[@(FunctionType_camera),@(FunctionType_meiyan),@(FunctionType_share),@(FunctionType_upHot)];
  200. }
  201. NSArray *shareTypeA = [NSArray arrayWithArray:[common share_type]];
  202. NSMutableArray *m_functionArr = [NSMutableArray arrayWithArray:functionArr];
  203. NSMutableArray *m_functionImgArr = [NSMutableArray arrayWithArray:functionImgArr];
  204. NSMutableArray *m_funcTypeArr = [NSMutableArray arrayWithArray:_funcTypeArr];
  205. if(shareTypeA.count<=0){
  206. [m_functionArr removeObject:YZMsg(@"分享")];
  207. [m_functionImgArr removeObject:@"pre_fun_share"];
  208. [m_funcTypeArr removeObject:@(FunctionType_share)];
  209. functionArr = [NSArray arrayWithArray:m_functionArr];
  210. functionImgArr = [NSArray arrayWithArray:m_functionImgArr];
  211. _funcTypeArr = [NSArray arrayWithArray:m_funcTypeArr];
  212. }
  213. UIView *funView = [[UIView alloc]init];
  214. [self addSubview:funView];
  215. [funView mas_makeConstraints:^(MASConstraintMaker *make) {
  216. make.bottom.equalTo(startLiveBtn.mas_top).offset(-20);
  217. make.centerX.equalTo(startLiveBtn.mas_centerX);
  218. }];
  219. for(int i = 0; i < functionArr.count; i ++){
  220. UIButton *funbtn = [UIButton buttonWithType:0];
  221. [funbtn addTarget:self action:@selector(funBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  222. funbtn.tag = 10000+i;
  223. [funView addSubview:funbtn];
  224. if(i == 0){
  225. [funbtn mas_makeConstraints:^(MASConstraintMaker *make) {
  226. make.left.equalTo(funView.mas_left).offset(5);
  227. make.width.height.mas_equalTo(70);
  228. make.bottom.equalTo(funView.mas_bottom).offset(-10);
  229. make.top.equalTo(funView.mas_top);
  230. }];
  231. openGoodsCar = funbtn;
  232. openGoodsCar.selected = NO;
  233. }else{
  234. if(i == functionArr.count -1){
  235. [funbtn mas_makeConstraints:^(MASConstraintMaker *make) {
  236. make.left.equalTo(funView.mas_left).offset(i * 70);
  237. make.right.equalTo(funView.mas_right).offset(-5);
  238. make.top.equalTo(funView.mas_top);
  239. make.width.mas_equalTo(70);
  240. }];
  241. // preTypeBtn = funbtn;
  242. }else{
  243. [funbtn mas_makeConstraints:^(MASConstraintMaker *make) {
  244. make.left.equalTo(funView.mas_left).offset(i * 70);
  245. make.top.equalTo(funView.mas_top);
  246. make.width.mas_equalTo(70);
  247. }];
  248. }
  249. }
  250. UIImageView *img = [[UIImageView alloc]init];
  251. img.image =[UIImage imageNamed:functionImgArr[i]];
  252. img.tag = 20000+i;
  253. [funbtn addSubview:img];
  254. [img mas_makeConstraints:^(MASConstraintMaker *make) {
  255. make.centerX.equalTo(funbtn.mas_centerX);
  256. make.top.equalTo(funbtn.mas_top);
  257. make.width.height.mas_equalTo(30);
  258. }];
  259. UILabel *titleLb = [[UILabel alloc]init];
  260. titleLb.textAlignment = NSTextAlignmentCenter;
  261. titleLb.font = [UIFont systemFontOfSize:14];
  262. titleLb.textColor = UIColor.whiteColor;
  263. titleLb.text = functionArr[i];
  264. titleLb.tag = 30000+i;
  265. [funbtn addSubview:titleLb];
  266. [titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  267. make.centerX.equalTo(funbtn.mas_centerX);
  268. make.top.equalTo(img.mas_bottom).offset(5);
  269. }];
  270. }
  271. // if ([isShop isEqual:@"1"]) {
  272. // cartBtn.hidden = NO;
  273. // }
  274. }
  275. -(void)funBtnClick:(UIButton *)sender{
  276. NSInteger index = sender.tag - 10000;
  277. id aa = _funcTypeArr[index];
  278. FunctionType type = [aa integerValue];
  279. if (type == FunctionType_shop) {
  280. // if(UIImageView *img in sender.subviews)
  281. openGoodsCar.selected = !openGoodsCar.selected;
  282. _cartOpen = openGoodsCar.selected;
  283. if(openGoodsCar.selected){
  284. for (UIImageView *subImg in sender.subviews) {
  285. if(subImg.tag == sender.tag +10000){
  286. subImg.image =[UIImage imageNamed:@"pre_fun_shopsel"];
  287. }
  288. }
  289. for (UILabel *subLb in sender.subviews) {
  290. if(subLb.tag == sender.tag +20000){
  291. subLb.textColor = Normal_Color;
  292. }
  293. }
  294. }else{
  295. for (UIImageView *subImg in sender.subviews) {
  296. if(subImg.tag == sender.tag +10000){
  297. subImg.image =[UIImage imageNamed:@"pre_fun_shop"];
  298. }
  299. }
  300. for (UILabel *subLb in sender.subviews) {
  301. if(subLb.tag == sender.tag +20000){
  302. subLb.textColor = UIColor.whiteColor;
  303. }
  304. }
  305. }
  306. }else if (type == FunctionType_camera){
  307. [self rotateCamera];
  308. }else if (type == FunctionType_meiyan){
  309. [self showFitterView];
  310. }else if (type == FunctionType_share){
  311. NSDictionary *shareDic = @{@"hostName":[Config getOwnNicename],@"thumb_s":[Config getUserAvatarThumb],@"hostId":[Config getOwnID],@"liveTitle":textPlaceholdLabel.text};
  312. [YBShareView showShareWithType:RKShareType_LivePre parameter:shareDic commplete:^(int codeEvent, NSString *nums) {
  313. }];
  314. }else if (type == FunctionType_upHot){
  315. [self toUphot];
  316. }
  317. }
  318. -(void)toUphot{
  319. if (self.livePreEvent) {
  320. self.livePreEvent(@"预览-上热门", @"");
  321. }
  322. }
  323. //选择频道
  324. - (void)showAllClassView{
  325. YBWeakSelf;
  326. startLiveClassVC *vc = [[startLiveClassVC alloc]init];
  327. vc.classID = liveClassID;
  328. vc.block = ^(NSDictionary * _Nonnull dic) {
  329. liveClassID = minstr([dic valueForKey:@"id"]);
  330. liveClassLabel.text = minstr([dic valueForKey:@"name"]);
  331. [weakSelf setSelClass];
  332. };
  333. vc.modalPresentationStyle = UIModalPresentationFullScreen;
  334. // vc.modalPresentationStyle = UIModalPresentationFullScreen;
  335. // self.animator = [[ZFModalTransitionAnimator alloc] initWithModalViewController:vc];
  336. // self.animator.bounces = NO;
  337. // self.animator.behindViewAlpha = 1;
  338. // self.animator.behindViewScale = 0.5f;
  339. // self.animator.transitionDuration = 0.4f;
  340. // vc.transitioningDelegate = self.animator;
  341. // self.animator.dragable = YES;
  342. // self.animator.direction = ZFModalTransitonDirectionRight;
  343. // [self presentViewController:vc animated:YES completion:nil];
  344. [[[YBBaseAppDelegate sharedAppDelegate] topViewController]presentViewController:vc animated:YES completion:nil];
  345. }
  346. -(void)clickCartBtn:(UIButton *)sender {
  347. sender.selected = !sender.selected;
  348. _cartOpen = sender.selected;
  349. }
  350. - (void)hidePreTextView{
  351. [liveTitleTextView resignFirstResponder];
  352. }
  353. #pragma mark - 定位开关
  354. - (void)locationSwitchBtnClick{
  355. if ([locationLabel.text isEqual:YZMsg(@"开定位")]) {
  356. loactionImgView.image = [UIImage imageNamed:@"pre_location"];
  357. locationLabel.text = [cityDefault getLocationCity];
  358. _locationSwitch = YES;
  359. }else{
  360. NSDictionary *contentDic = @{@"title":@"",@"msg":YZMsg(@"关闭定位,直播不会被附近的人看到,直播间人数可能会减少,确认关闭吗?"),@"left":YZMsg(@"取消"),@"right":YZMsg(@"坚决关闭")};
  361. [YBAlertView showAlertView:contentDic complete:^(int eventType) {
  362. if (eventType == 1) {
  363. loactionImgView.image = [UIImage imageNamed:@"pre_location_off"];
  364. locationLabel.text = YZMsg(@"开定位");
  365. _locationSwitch = NO;
  366. }
  367. }];
  368. }
  369. }
  370. #pragma mark - 切换
  371. -(void)rotateCamera {
  372. if (self.livePreEvent) {
  373. self.livePreEvent(@"预览-切换", @"");
  374. }
  375. }
  376. - (void)doClosePreView {
  377. if (self.livePreEvent) {
  378. self.livePreEvent(@"预览-关闭", @"");
  379. }
  380. }
  381. -(void)clickStartLiveBtn:(UIButton *)sender {
  382. if (self.livePreEvent) {
  383. self.livePreEvent(@"预览-开直播", @"");
  384. }
  385. }
  386. -(void)showFitterView {
  387. if (self.livePreEvent) {
  388. self.livePreEvent(@"预览-美颜", @"");
  389. }
  390. }
  391. -(void)setSelClass{
  392. if (self.livePreEvent) {
  393. self.livePreEvent(@"预览-分类", liveClassID);
  394. }
  395. }
  396. - (void)share:(UIButton *)sender{
  397. if ([selectShareName isEqual:sender.titleLabel.text]) {
  398. sender.selected = NO;
  399. selectShareName = @"";
  400. }else{
  401. sender.selected = YES;
  402. selectShareName = sender.titleLabel.text;
  403. for (UIButton *btn in preShareBtnArray) {
  404. if (btn != sender) {
  405. btn.selected = NO;
  406. }
  407. }
  408. }
  409. if (self.livePreEvent) {
  410. self.livePreEvent(@"预览-分享", selectShareName);
  411. }
  412. }
  413. -(void)doUploadPicture{
  414. /*
  415. YBWeakSelf;
  416. RKActionSheet *sheet = [[RKActionSheet alloc]initWithTitle:@""];
  417. [sheet addActionWithType:RKSheet_Default andTitle:YZMsg(@"相机") complete:^{
  418. [weakSelf selectThumbWithType:UIImagePickerControllerSourceTypeCamera];
  419. }];
  420. [sheet addActionWithType:RKSheet_Default andTitle:YZMsg(@"相册") complete:^{
  421. [weakSelf selectThumbWithType:UIImagePickerControllerSourceTypePhotoLibrary];
  422. }];
  423. [sheet addActionWithType:RKSheet_Cancle andTitle:YZMsg(@"取消") complete:^{
  424. }];
  425. [sheet showSheet];
  426. */
  427. //安卓直接跳相册->去掉弹窗2020-7-2
  428. [self selectPhotos];
  429. }
  430. -(void)selectPhotos {
  431. TZImagePickerController *imagePC = [[TZImagePickerController alloc]initWithMaxImagesCount:1 delegate:self];
  432. imagePC.preferredLanguage = [lagType isEqual:ZH_CN] ? @"zh-Hans":@"en";
  433. imagePC.showSelectBtn = YES;
  434. imagePC.allowCrop = NO;
  435. imagePC.allowPickingOriginalPhoto = NO;
  436. imagePC.oKButtonTitleColorNormal = Pink_Cor;
  437. imagePC.allowTakePicture = YES;
  438. imagePC.allowTakeVideo = NO;
  439. imagePC.allowPickingVideo = NO;
  440. imagePC.allowPickingMultipleVideo = NO;
  441. imagePC.modalPresentationStyle = 0;
  442. [[[YBBaseAppDelegate sharedAppDelegate] topViewController]presentViewController:imagePC animated:YES completion:nil];
  443. }
  444. - (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto{
  445. _thumbImage = photos[0];
  446. [preThumbBtn setImage:_thumbImage forState:UIControlStateNormal];
  447. thumbLabel.text = YZMsg(@"更换封面");
  448. thumbLabel.backgroundColor = RGB_COLOR(@"#0000000", 0.3);
  449. }
  450. -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
  451. NSString *type = [info objectForKey:UIImagePickerControllerMediaType];
  452. if ([type isEqualToString:@"public.image"])
  453. {
  454. //先把图片转成NSData
  455. UIImage* image = [info objectForKey:@"UIImagePickerControllerEditedImage"];
  456. _thumbImage = image;
  457. [preThumbBtn setImage:image forState:UIControlStateNormal];
  458. thumbLabel.text = YZMsg(@"更换封面");
  459. thumbLabel.backgroundColor = RGB_COLOR(@"#0000000", 0.3);
  460. }
  461. [picker dismissViewControllerAnimated:YES completion:nil];
  462. }
  463. -(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
  464. [picker dismissViewControllerAnimated:YES completion:nil];
  465. }
  466. - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
  467. if ([UIDevice currentDevice].systemVersion.floatValue < 11) {
  468. return;
  469. }
  470. if ([viewController isKindOfClass:NSClassFromString(@"PUPhotoPickerHostViewController")]) {
  471. [viewController.view.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  472. if (obj.frame.size.width < 42) {
  473. [viewController.view sendSubviewToBack:obj];
  474. *stop = YES;
  475. }
  476. }];
  477. }
  478. }
  479. - (void)textViewDidChange:(UITextView *)textView {
  480. if (textView.text.length == 0) {
  481. textPlaceholdLabel.text = YZMsg(@"给直播写个标题吧");
  482. }else{
  483. textPlaceholdLabel.text = @"";
  484. }
  485. _inputTitleStr = textView.text;
  486. }
  487. @end