//
|
// PPTVPppView.m
|
// BuWanVideo2.0
|
//
|
// Created by Aeline on 2021/5/15.
|
// Copyright © 2021 com.yeshi.buwansheque.ios. All rights reserved.
|
//
|
|
#import "PPTVPppView.h"
|
#import "PPTVPopCell.h"
|
|
@interface PPTVPppView () <UITableViewDelegate, UITableViewDataSource, UIGestureRecognizerDelegate>
|
@property (nonatomic, nullable, strong) UIView *viewBG;
|
@property (nonatomic, nullable, strong) UITableView *tabView;
|
@property (nonatomic, nullable, strong) UIImageView *imageViewTT;
|
|
@property(nonatomic, nullable, strong) NSArray *arrayContent;
|
@end
|
|
@implementation PPTVPppView
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
{
|
self = [super initWithFrame:frame];
|
if (self) {
|
self.backgroundColor = UICOLOR_FROM_RGB(0x000000, 0.5);
|
|
self.userInteractionEnabled = YES;
|
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismisView)];
|
tap.delegate = self;
|
[self addGestureRecognizer:tap];
|
|
self.arrayContent = @[@{@"name" : @"刷新", @"icon" : @"pptv_refresh"} ,
|
@{@"name" : @"复制链接", @"icon" : @"pptv_copy"} ,
|
@{@"name" : @"用其他浏览器打开", @"icon" : @"pptv_other"}];
|
[self setupViewConfig];
|
}
|
return self;
|
}
|
|
- (void)setupViewConfig {
|
[self addSubview:self.imageViewTT];
|
self.imageViewTT.sd_layout.rightSpaceToView(self, 8).topSpaceToView(self, 1).widthIs(33).heightIs(24);
|
|
[self addSubview:self.viewBG];
|
self.viewBG.sd_layout.rightSpaceToView(self, 5).topSpaceToView(self, 8).widthIs(180).heightIs(138);
|
self.viewBG.sd_cornerRadius = @6;
|
|
[self.viewBG addSubview:self.tabView];
|
}
|
|
- (void)dismisView {
|
self.hidden = YES;
|
}
|
|
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
|
// 输出点击的view的类名,则不截获Touch事件
|
NSLog(@"%@", NSStringFromClass([touch.view class]));
|
if ([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]) {
|
if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {
|
return NO;
|
}
|
}
|
return YES;
|
}
|
|
#pragma mark UITableViewDelegate, UITableViewDataSource
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
[self dismisView];
|
if (_delegate && [_delegate respondsToSelector:@selector(selectType:)]) {
|
[_delegate selectType:self.arrayContent[indexPath.section][@"name"]];
|
}
|
}
|
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
return self.arrayContent.count;
|
}
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
return 1;
|
}
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
NSString *cellIden = @"PPTVPopCell";
|
PPTVPopCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIden];
|
if (!cell){
|
cell = [[PPTVPopCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIden];
|
}
|
cell.index = indexPath.section;
|
cell.data = self.arrayContent[indexPath.section];
|
return cell;
|
}
|
|
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
|
UIView *view = [[UIView alloc] init];
|
return view;
|
}
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
|
return CGFLOAT_MIN;
|
}
|
|
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
|
UIView *view = [[UIView alloc] init];
|
return view;
|
}
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
|
return CGFLOAT_MIN;
|
}
|
|
- (UIView *)viewBG {
|
if (!_viewBG) {
|
_viewBG = [[UIView alloc] init];
|
_viewBG.backgroundColor = [UIColor whiteColor];
|
}
|
return _viewBG;
|
}
|
|
- (UITableView *)tabView {
|
if (!_tabView) {
|
_tabView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, (172), 137) style:UITableViewStyleGrouped];
|
_tabView.delegate = self;
|
_tabView.dataSource = self;
|
_tabView.estimatedRowHeight = 47;
|
_tabView.estimatedSectionFooterHeight = 0;
|
_tabView.estimatedSectionHeaderHeight = 0;
|
_tabView.backgroundColor = [UIColor whiteColor];
|
_tabView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
_tabView.showsVerticalScrollIndicator = YES;
|
_tabView.scrollEnabled = NO;
|
}
|
return _tabView;
|
}
|
|
- (UIImageView *)imageViewTT {
|
if (!_imageViewTT) {
|
_imageViewTT = [[UIImageView alloc] init];
|
_imageViewTT.image = [UIImage imageNamed:@"pptv_bg"];
|
}
|
return _imageViewTT;
|
}
|
@end
|