Commit 1bd7c2c270b8311fd35cf1662d70fc0653e10c3a

Authored by 王军波
1 parent 64f045c6

功能按钮更换

LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/Controller/LVCLiveViewController.m
@@ -47,6 +47,8 @@ @@ -47,6 +47,8 @@
47 [self.view addSubview:self.quitButton]; 47 [self.view addSubview:self.quitButton];
48 [self.view addSubview:self.changeCameraButton]; 48 [self.view addSubview:self.changeCameraButton];
49 [self.view addSubview:self.openFilterButton]; 49 [self.view addSubview:self.openFilterButton];
  50 + [self.view addSubview:self.openFlashButton];
  51 + [self.view addSubview:self.filterView];
50 52
51 // 初始化推流 53 // 初始化推流
52 NSString *activityId = [NSString stringWithFormat:@"%d%d%d%d%d",arc4random()%9,arc4random()%9,arc4random()%9,arc4random()%9,arc4random()%9]; 54 NSString *activityId = [NSString stringWithFormat:@"%d%d%d%d%d",arc4random()%9,arc4random()%9,arc4random()%9,arc4random()%9,arc4random()%9];
@@ -62,8 +64,6 @@ @@ -62,8 +64,6 @@
62 [self setStreamerCfg]; 64 [self setStreamerCfg];
63 65
64 [self addObservers]; 66 [self addObservers];
65 -  
66 - [self addButton:@"闪光灯" frame:CGRectMake(190, 100, 80, 40) action:@selector(openFlash)];  
67 67
68 UITapGestureRecognizer * singleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap:)]; 68 UITapGestureRecognizer * singleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap:)];
69 singleRecognizer.delegate = self; 69 singleRecognizer.delegate = self;
@@ -104,20 +104,15 @@ @@ -104,20 +104,15 @@
104 #pragma mark - UIButton Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 104 #pragma mark - UIButton Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
105 - (void)startCapture:(UIButton *)button { // 开始推流 105 - (void)startCapture:(UIButton *)button { // 开始推流
106 106
107 - button.selected = !button.selected; 107 + [_prepareView removeFromSuperview];
108 108
109 - if (button.selected) {  
110 - [_kitCN startStream:^{  
111 - NSLog(@"开启推流成功 ------- success");  
112 - } failure:^(NSDictionary *errorDic) {  
113 - NSString *str=[[NSMutableString alloc] initWithData:errorDic[@"errorMessage"] encoding:NSUTF8StringEncoding];  
114 - NSLog(@"%@",str);  
115 - [self toast:errorDic[@"errorMessage"]];  
116 - }];  
117 - }else{  
118 -  
119 - [_kitCN stopStream];  
120 - } 109 + [_kitCN startStream:^{
  110 + NSLog(@"开启推流成功 ------- success");
  111 + } failure:^(NSDictionary *errorDic) {
  112 + NSString *str=[[NSMutableString alloc] initWithData:errorDic[@"errorMessage"] encoding:NSUTF8StringEncoding];
  113 + NSLog(@"%@",str);
  114 + [self toast:errorDic[@"errorMessage"]];
  115 + }];
121 } 116 }
122 117
123 118
@@ -149,14 +144,14 @@ @@ -149,14 +144,14 @@
149 } else { 144 } else {
150 145
151 _filterView.hidden = YES; 146 _filterView.hidden = YES;
152 -  
153 } 147 }
154 } 148 }
155 149
156 150
157 - (void)changeCamera:(UIButton *)button { // 转换前后置摄像头 151 - (void)changeCamera:(UIButton *)button { // 转换前后置摄像头
158 152
159 -// button.selected = !button.selected; 153 + button.selected = !button.selected;
  154 + _openFlashButton.hidden = !_openFlashButton.hidden;
160 // if (button.selected) { 155 // if (button.selected) {
161 // _kitCN.cameraPosition = AVCaptureDevicePositionBack; 156 // _kitCN.cameraPosition = AVCaptureDevicePositionBack;
162 // }else{ 157 // }else{
@@ -167,8 +162,9 @@ @@ -167,8 +162,9 @@
167 } 162 }
168 163
169 164
170 -- (void)openFlash { // 闪光灯 165 +- (void)openFlash:(UIButton *)button { // 闪光灯
171 166
  167 + button.selected = !button.selected;
172 [_kitCN toggleTorch]; 168 [_kitCN toggleTorch];
173 // [_kitCN setTorchMode:AVCaptureTorchModeOn]; 169 // [_kitCN setTorchMode:AVCaptureTorchModeOn];
174 } 170 }
@@ -195,6 +191,10 @@ @@ -195,6 +191,10 @@
195 CGPoint point = [self convertToPointOfInterestFromViewCoordinates:current]; 191 CGPoint point = [self convertToPointOfInterestFromViewCoordinates:current];
196 [_kitCN exposureAtPoint:point]; 192 [_kitCN exposureAtPoint:point];
197 [_kitCN focusAtPoint:point]; 193 [_kitCN focusAtPoint:point];
  194 +
  195 + if ([_prepareView.titleTextField isFirstResponder]) {
  196 + [_prepareView.titleTextField resignFirstResponder];
  197 + }
198 } 198 }
199 199
200 #pragma mark - notification !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 200 #pragma mark - notification !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -399,10 +399,22 @@ @@ -399,10 +399,22 @@
399 if (!_prepareView) { 399 if (!_prepareView) {
400 _prepareView = [[LVCUGCLivePrepareView alloc] initWithFrame:self.view.bounds]; 400 _prepareView = [[LVCUGCLivePrepareView alloc] initWithFrame:self.view.bounds];
401 [_prepareView.startButton addTarget:self action:@selector(startCapture:) forControlEvents:UIControlEventTouchUpInside]; 401 [_prepareView.startButton addTarget:self action:@selector(startCapture:) forControlEvents:UIControlEventTouchUpInside];
  402 + UITapGestureRecognizer * tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap:)];
  403 + tapRecognizer.delegate = self;
  404 + [_prepareView addGestureRecognizer:tapRecognizer];
402 } 405 }
403 return _prepareView; 406 return _prepareView;
404 } 407 }
405 408
  409 +- (FilterFunctionView *)filterView
  410 +{
  411 + if (!_filterView) {
  412 + _filterView = [[FilterFunctionView alloc] initWithFrame:CGRectMake(0, 75, SCREEN_WIDTH, 200)];
  413 + _filterView.hidden = YES;
  414 + }
  415 + return _filterView;
  416 +}
  417 +
406 - (UIView *)captureView { // 拍摄视图 418 - (UIView *)captureView { // 拍摄视图
407 419
408 if (!_captureView) { 420 if (!_captureView) {
@@ -415,7 +427,7 @@ @@ -415,7 +427,7 @@
415 - (UIButton *)quitButton { 427 - (UIButton *)quitButton {
416 428
417 if (!_quitButton) { 429 if (!_quitButton) {
418 - _quitButton = [self createButtonWithFrame:CGRectMake(SCREEN_WIDTH - 50, 30, 40, 40) image:@"LiveCloseNormal" selected:@"LiveCloseTouch"]; 430 + _quitButton = [self createButtonWithFrame:CGRectMake(SCREEN_WIDTH - 50, 30, 35, 35) image:@"LiveCloseNormal" selected:@"LiveCloseTouch"];
419 [_quitButton addTarget:self action:@selector(quitBtnClick) forControlEvents:UIControlEventTouchUpInside]; 431 [_quitButton addTarget:self action:@selector(quitBtnClick) forControlEvents:UIControlEventTouchUpInside];
420 } 432 }
421 return _quitButton; 433 return _quitButton;
@@ -424,7 +436,7 @@ @@ -424,7 +436,7 @@
424 - (UIButton *)changeCameraButton { 436 - (UIButton *)changeCameraButton {
425 437
426 if (!_changeCameraButton) { 438 if (!_changeCameraButton) {
427 - _changeCameraButton = [self createButtonWithFrame:CGRectMake(SCREEN_WIDTH - 100, 30, 40, 40) image:@"LiveCloseNormal" selected:@"LiveCloseTouch"]; 439 + _changeCameraButton = [self createButtonWithFrame:CGRectMake(SCREEN_WIDTH - 100, 30, 35, 35) image:@"camera" selected:@"Select the camera"];
428 [_changeCameraButton addTarget:self action:@selector(changeCamera:) forControlEvents:UIControlEventTouchUpInside]; 440 [_changeCameraButton addTarget:self action:@selector(changeCamera:) forControlEvents:UIControlEventTouchUpInside];
429 } 441 }
430 return _changeCameraButton; 442 return _changeCameraButton;
@@ -433,7 +445,9 @@ @@ -433,7 +445,9 @@
433 - (UIButton *)openFlashButton { 445 - (UIButton *)openFlashButton {
434 446
435 if (!_openFlashButton) { 447 if (!_openFlashButton) {
436 - 448 + _openFlashButton = [self createButtonWithFrame:CGRectMake(SCREEN_WIDTH - 100, 75, 35, 35) image:@"open flash" selected:@"Flash off"];
  449 + _openFlashButton.hidden = YES;
  450 + [_openFlashButton addTarget:self action:@selector(openFlash:) forControlEvents:UIControlEventTouchUpInside];
437 } 451 }
438 return _openFlashButton; 452 return _openFlashButton;
439 } 453 }
@@ -441,7 +455,7 @@ @@ -441,7 +455,7 @@
441 - (UIButton *)openFilterButton { 455 - (UIButton *)openFilterButton {
442 456
443 if (!_openFilterButton) { 457 if (!_openFilterButton) {
444 - _openFilterButton = [self createButtonWithFrame:CGRectMake(SCREEN_WIDTH - 150, 30, 40, 40) image:@"LiveCloseNormal" selected:@"LiveCloseTouch"]; 458 + _openFilterButton = [self createButtonWithFrame:CGRectMake(SCREEN_WIDTH - 150, 30, 35, 35) image:@"Is closed" selected:@"Is open"];
445 [_openFilterButton addTarget:self action:@selector(openFilter:) forControlEvents:UIControlEventTouchUpInside]; 459 [_openFilterButton addTarget:self action:@selector(openFilter:) forControlEvents:UIControlEventTouchUpInside];
446 } 460 }
447 return _openFilterButton; 461 return _openFilterButton;
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/View/FilterFunctionView.m
@@ -135,7 +135,7 @@ @@ -135,7 +135,7 @@
135 - (UIPickerView *)effectPicker 135 - (UIPickerView *)effectPicker
136 { 136 {
137 if (!_effectPicker) { 137 if (!_effectPicker) {
138 - _effectPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(8, 130, self.bounds.size.width-16, 100)]; 138 + _effectPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(8, 20, self.bounds.size.width-16, 100)];
139 _effectPicker.showsSelectionIndicator=YES; 139 _effectPicker.showsSelectionIndicator=YES;
140 _effectPicker.tintColor = [UIColor whiteColor]; 140 _effectPicker.tintColor = [UIColor whiteColor];
141 _effectPicker.dataSource = self; 141 _effectPicker.dataSource = self;
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/View/LVCUGCLivePrepareView.h
@@ -12,4 +12,6 @@ @@ -12,4 +12,6 @@
12 12
13 @property (nonatomic, strong) UIButton *startButton; 13 @property (nonatomic, strong) UIButton *startButton;
14 14
  15 +@property (nonatomic, strong) UITextField *titleTextField;
  16 +
15 @end 17 @end
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/View/LVCUGCLivePrepareView.m
@@ -12,8 +12,6 @@ @@ -12,8 +12,6 @@
12 12
13 @property (nonatomic, strong) UIImageView *iconView; 13 @property (nonatomic, strong) UIImageView *iconView;
14 14
15 -@property (nonatomic, strong) UITextField *titleTextField;  
16 -  
17 @property (nonatomic, strong) UIView *lineView; 15 @property (nonatomic, strong) UIView *lineView;
18 16
19 @end 17 @end
@@ -51,8 +49,13 @@ @@ -51,8 +49,13 @@
51 49
52 if (!_titleTextField) { 50 if (!_titleTextField) {
53 _titleTextField = [[UITextField alloc] initWithFrame:CGRectMake(110, SCREEN_HEIGHT * 0.35 + 50, SCREEN_WIDTH - 120, 30)]; 51 _titleTextField = [[UITextField alloc] initWithFrame:CGRectMake(110, SCREEN_HEIGHT * 0.35 + 50, SCREEN_WIDTH - 120, 30)];
54 - _titleTextField.placeholder = @"起一个名字开始直播吧~";  
55 - _titleTextField.font = [UIFont systemFontOfSize:20]; 52 +
  53 + NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc]initWithString:@"起个名字开始直播~"];
  54 +
  55 +
  56 + _titleTextField.attributedPlaceholder = placeholder;
  57 +
  58 + _titleTextField.font = [UIFont systemFontOfSize:19];
56 } 59 }
57 return _titleTextField; 60 return _titleTextField;
58 } 61 }
@@ -70,7 +73,7 @@ @@ -70,7 +73,7 @@
70 73
71 if (!_startButton) { 74 if (!_startButton) {
72 _startButton = [UIButton buttonWithType:UIButtonTypeCustom]; 75 _startButton = [UIButton buttonWithType:UIButtonTypeCustom];
73 - _startButton.frame = CGRectMake(30, SCREEN_HEIGHT * 0.6, SCREEN_WIDTH - 60, 38); 76 + _startButton.frame = CGRectMake(30, SCREEN_HEIGHT * 0.62, SCREEN_WIDTH - 60, 38);
74 _startButton.backgroundColor = [UIColor redColor]; 77 _startButton.backgroundColor = [UIColor redColor];
75 [_startButton setTitle:@"开始直播" forState:UIControlStateNormal]; 78 [_startButton setTitle:@"开始直播" forState:UIControlStateNormal];
76 _startButton.titleLabel.font = [UIFont systemFontOfSize:20]; 79 _startButton.titleLabel.font = [UIFont systemFontOfSize:20];