|
32 | 32 | static NSString *const kVIdeoDeviceListHeaderID = @"kVIdeoDeviceListHeaderID"; |
33 | 33 | static NSInteger const kLimit = 100; |
34 | 34 |
|
35 | | -@interface TIoTDemoHomeViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout> |
| 35 | + |
| 36 | +@interface MutiUITableViewCell : UITableViewCell |
| 37 | +@end |
| 38 | +@implementation MutiUITableViewCell |
| 39 | +- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ |
| 40 | + if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { |
| 41 | + self.multipleSelectionBackgroundView = [UIView new]; |
| 42 | + self.tintColor = [UIColor redColor]; |
| 43 | + } |
| 44 | + return self; |
| 45 | +} |
| 46 | +@end |
| 47 | + |
| 48 | +@interface TIoTDemoHomeViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout, UITableViewDataSource, UITableViewDelegate> |
36 | 49 | @property (nonatomic, strong) UICollectionView *collectionView; |
37 | 50 | @property (nonatomic, strong) NSMutableArray *dataArray; |
38 | 51 | @property (nonatomic, assign) BOOL isShowSameScreenChoiceIcon; |
39 | 52 | @property (nonatomic, strong) NSMutableArray *selectedArray; |
40 | 53 | @property (nonatomic, assign) BOOL isNVR; |
| 54 | + |
| 55 | +@property (strong, nonatomic) UIView *contxtTableView; |
| 56 | +@property (strong, nonatomic) UITableView *tableView; |
| 57 | +@property (strong, nonatomic) NSMutableArray *listData; |
| 58 | +@property (strong, nonatomic) NSString *currentDeviceName; |
41 | 59 | @end |
42 | 60 |
|
43 | 61 | @implementation TIoTDemoHomeViewController |
@@ -232,7 +250,7 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collection |
232 | 250 |
|
233 | 251 | TIoTDemoCustomSheetView *customActionSheet = [[TIoTDemoCustomSheetView alloc]init]; |
234 | 252 | cell.moreActionBlock = ^{ |
235 | | - NSArray *actionTitleArray = @[@"预览", @"IPC双向通话", @"IPC双向通话-只推流", @"回放",@"图片流(mjpeg)",@"取消"]; |
| 253 | + NSArray *actionTitleArray = @[@"预览", @"IPC双向通话", @"IPC双向通话-只推流", @"回放",@"图片流(mjpeg)", @"多通道选择", @"取消"]; |
236 | 254 |
|
237 | 255 | ChooseFunctionBlock previewVideoBlock = ^(TIoTDemoCustomSheetView *view){ |
238 | 256 | DDLogVerbose(@"预览"); |
@@ -299,11 +317,30 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collection |
299 | 317 | [customActionSheet removeFromSuperview]; |
300 | 318 | }; |
301 | 319 |
|
| 320 | + ChooseFunctionBlock channelVideoBlock = ^(TIoTDemoCustomSheetView *view){ |
| 321 | + DDLogVerbose(@"多通道"); |
| 322 | +// TIoTDemoSameScreenVC *sameScreenVC = [[TIoTDemoSameScreenVC alloc]init]; |
| 323 | +// sameScreenVC.isNVRType = YES; |
| 324 | +// sameScreenVC.NVRDeviceName = model.DeviceName; |
| 325 | +// [sameScreenVC setupSameScreenArray:self.selectedArray]; |
| 326 | +// [weakSelf.navigationController pushViewController:sameScreenVC animated:YES]; |
| 327 | +// [weakSelf resetDeviceListStatus]; |
| 328 | + |
| 329 | + weakSelf.currentDeviceName = model.DeviceName; |
| 330 | + [weakSelf.view addSubview:weakSelf.contxtTableView]; |
| 331 | + [UIView animateWithDuration:0.3 animations:^{ |
| 332 | + [weakSelf.contxtTableView setFrame:CGRectMake(0, 0, kScreenWidth, weakSelf.view.bounds.size.height)]; |
| 333 | +// [weakSelf.view layoutIfNeeded]; |
| 334 | + }]; |
| 335 | + |
| 336 | + [customActionSheet removeFromSuperview]; |
| 337 | + }; |
| 338 | + |
302 | 339 | ChooseFunctionBlock cancelBlock = ^(TIoTDemoCustomSheetView *view) { |
303 | 340 | DDLogVerbose(@"取消"); |
304 | 341 | [view removeFromSuperview]; |
305 | 342 | }; |
306 | | - NSArray *actionBlockArray = @[previewVideoBlock, videoCallBlock, videoPushBlock, playbackVideoBlock,mjpegVideoBlock,cancelBlock]; |
| 343 | + NSArray *actionBlockArray = @[previewVideoBlock, videoCallBlock, videoPushBlock, playbackVideoBlock,mjpegVideoBlock, channelVideoBlock, cancelBlock]; |
307 | 344 |
|
308 | 345 |
|
309 | 346 | [customActionSheet sheetViewTopTitleArray:actionTitleArray withMatchBlocks:actionBlockArray]; |
@@ -440,14 +477,127 @@ - (NSMutableArray *)selectedArray { |
440 | 477 | return _selectedArray; |
441 | 478 | } |
442 | 479 |
|
443 | | -/* |
444 | | -#pragma mark - Navigation |
| 480 | +#pragma mark - 多选 |
| 481 | +- (void)dismissCancle { |
| 482 | + [UIView animateWithDuration:0.3 animations:^{ |
| 483 | + [self.contxtTableView setFrame:CGRectMake(0, kScreenHeight, kScreenWidth, kScreenHeight)]; |
| 484 | + }]; |
| 485 | +} |
| 486 | + |
| 487 | +- (UIView *)contxtTableView { |
| 488 | + if (!_contxtTableView) { |
| 489 | + _contxtTableView = [[UIView alloc] initWithFrame:CGRectMake(0, kScreenHeight, kScreenWidth, kScreenHeight)]; |
| 490 | + [_contxtTableView setBackgroundColor:UIColor.clearColor]; |
| 491 | + [_contxtTableView addSubview:self.tableView]; |
| 492 | + |
| 493 | + [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { |
| 494 | + make.left.right.bottom.equalTo(_contxtTableView); |
| 495 | + make.height.mas_equalTo(370); |
| 496 | + }]; |
| 497 | + [self.tableView setEditing:YES animated:NO]; |
| 498 | + } |
| 499 | + return _contxtTableView; |
| 500 | +} |
| 501 | + |
| 502 | +- (UITableView *)tableView{ |
| 503 | + if (!_tableView) { |
| 504 | + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 370)]; |
| 505 | + _tableView.dataSource = self; |
| 506 | + _tableView.delegate = self; |
| 507 | + _tableView.backgroundColor = [UIColor whiteColor]; |
| 508 | + _tableView.tableFooterView = [[UIView alloc] init]; |
| 509 | + [_tableView registerClass:[MutiUITableViewCell class] forCellReuseIdentifier:@"Cell"]; |
| 510 | + } |
| 511 | + return _tableView; |
| 512 | +} |
| 513 | + |
| 514 | +#pragma mark -- UITabelViewDelegate And DataSource |
| 515 | +- (void)sectionHeaderSureClick { |
| 516 | + [self sectionHeaderCancelClick]; |
| 517 | + |
| 518 | + NSMutableArray *models = [[NSMutableArray alloc]init]; |
| 519 | + [[self.tableView indexPathsForSelectedRows] enumerateObjectsUsingBlock:^(NSIndexPath * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { |
| 520 | + |
| 521 | + TIoTExploreOrVideoDeviceModel *modell = [TIoTExploreOrVideoDeviceModel new]; |
| 522 | + modell.DeviceName = self.currentDeviceName; |
| 523 | + modell.Channel = [NSString stringWithFormat:@"%d",(int)obj.row]; |
| 524 | + [models addObject:modell]; |
| 525 | + }]; |
| 526 | + |
| 527 | + if (models.count < 1) { |
| 528 | + return; |
| 529 | + } |
| 530 | + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
| 531 | + TIoTDemoSameScreenVC *sameScreenVC = [[TIoTDemoSameScreenVC alloc]init]; |
| 532 | + sameScreenVC.isNVRType = NO; |
| 533 | + sameScreenVC.NVRDeviceName = self.currentDeviceName; |
| 534 | + [sameScreenVC setupSameScreenArray:models]; |
| 535 | + [self.navigationController pushViewController:sameScreenVC animated:YES]; |
| 536 | + }); |
| 537 | +} |
| 538 | + |
| 539 | +- (void)sectionHeaderCancelClick { |
| 540 | + [UIView animateWithDuration:0.3 animations:^{ |
| 541 | + [self.contxtTableView setFrame:CGRectMake(0, kScreenHeight, kScreenWidth, self.view.bounds.size.height)]; |
| 542 | + } completion:^(BOOL finished) { |
| 543 | + [self.contxtTableView removeFromSuperview]; |
| 544 | + }]; |
| 545 | +} |
| 546 | + |
| 547 | +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { |
| 548 | + return 50.0; // 返回你的 header view 的高度 |
| 549 | +} |
| 550 | + |
| 551 | +- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { |
| 552 | + |
| 553 | + static NSString *headerReuseIdentifier = @"TableSectionHeaderViewIdentifier"; |
| 554 | + UITableViewHeaderFooterView *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:headerReuseIdentifier]; |
| 555 | + if (!headerView) { |
| 556 | + headerView = [[UITableViewHeaderFooterView alloc] initWithReuseIdentifier:headerReuseIdentifier]; |
| 557 | + } |
| 558 | + headerView.textLabel.text = @"通道选择"; |
| 559 | + |
| 560 | + UIButton *bt1 = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 561 | + bt1.backgroundColor = UIColor.yellowColor; |
| 562 | + bt1.frame = CGRectMake(kScreenWidth-90, 0, 80, 50); |
| 563 | + [bt1 setTitle:@"确定" forState:UIControlStateNormal]; |
| 564 | + [bt1 addTarget:self action:@selector(sectionHeaderSureClick) forControlEvents:UIControlEventTouchUpInside]; |
| 565 | + |
| 566 | + UIButton *bt2 = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 567 | + bt2.backgroundColor = UIColor.orangeColor; |
| 568 | + bt2.frame = CGRectMake(kScreenWidth-90-90, 0, 80, 50); |
| 569 | + [bt2 setTitle:@"取消" forState:UIControlStateNormal]; |
| 570 | + [bt2 addTarget:self action:@selector(sectionHeaderCancelClick) forControlEvents:UIControlEventTouchUpInside]; |
| 571 | + |
| 572 | + [headerView.contentView addSubview:bt1]; |
| 573 | + [headerView.contentView addSubview:bt2]; |
| 574 | + return headerView; |
| 575 | +} |
| 576 | + |
| 577 | +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ |
| 578 | + return 4; |
| 579 | +} |
| 580 | + |
| 581 | +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ |
| 582 | + |
| 583 | + MutiUITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; |
| 584 | + cell.textLabel.text = [NSString stringWithFormat:@"第%ld条",(long)indexPath.row+1]; |
| 585 | + return cell; |
| 586 | +} |
| 587 | + |
| 588 | +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ |
| 589 | + return 80; |
| 590 | +} |
| 591 | + |
| 592 | +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ |
| 593 | + if (tableView.isEditing) { |
| 594 | + return; |
| 595 | + } |
| 596 | + [tableView deselectRowAtIndexPath:indexPath animated:YES]; |
| 597 | +} |
445 | 598 |
|
446 | | -// In a storyboard-based application, you will often want to do a little preparation before navigation |
447 | | -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { |
448 | | - // Get the new view controller using [segue destinationViewController]. |
449 | | - // Pass the selected object to the new view controller. |
| 599 | +- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{ |
| 600 | + return UITableViewCellEditingStyleDelete | UITableViewCellEditingStyleInsert; |
450 | 601 | } |
451 | | -*/ |
452 | 602 |
|
453 | 603 | @end |
0 commit comments