// // MONormalRightAlertView.m // MiMoLive // // Created by SuperC on 2025/6/8. // #define MONormalRightMenuCellHeight 54.0 #import "MONormalRightAlertView.h" #import "UIView+MOCornerRadius.h" #import "MONormalRightMenuCell.h" @interface MONormalRightAlertView () @property (weak, nonatomic) IBOutlet UIView *bgView; @property (weak, nonatomic) IBOutlet UITableView *tableView; @end @implementation MONormalRightAlertView + (instancetype)moNormalRightAlertView{ return [[[NSBundle mainBundle] loadNibNamed:@"MONormalRightAlertView" owner:self options:nil] firstObject]; } - (void)awakeFromNib{ [super awakeFromNib]; self.tableView.delegate = self; self.tableView.dataSource = self; self.tableView.rowHeight = MONormalRightMenuCellHeight; self.tableView.estimatedRowHeight = 0; self.tableView.estimatedSectionHeaderHeight = 0; self.tableView.estimatedSectionFooterHeight = 0; //iOS15适配 if (@available(iOS 15.0, *)) { self.tableView.sectionHeaderTopPadding = 0; } [self.tableView registerClass:[MONormalRightMenuCell class] forCellReuseIdentifier:MONormalRightMenuCell_ID]; } - (void)setDataArr:(NSArray *)dataArr{ _dataArr = dataArr; CGFloat theMenuHeight = dataArr.count * MONormalRightMenuCellHeight; self.menuViewHeight.constant = theMenuHeight; CGRect bgViewFrame = self.bgView.frame; bgViewFrame.size.height = theMenuHeight; self.bgView.frame = bgViewFrame; [self.bgView setCornerRadiusWithTopLeft:16.0 topRight:3.0 bottomRight:16.0 bottomLeft:16.0]; [self.tableView reloadData]; } - (IBAction)closeBtnClick:(id)sender { [self dismissVipMenuView]; } #pragma mark - UITableViewDelegate,UITableViewDataSource - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return self.dataArr.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ NSDictionary *dict = self.dataArr[indexPath.row]; MONormalRightMenuCell *cell = [tableView dequeueReusableCellWithIdentifier:MONormalRightMenuCell_ID]; if (cell == nil){ cell = [[MONormalRightMenuCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MONormalRightMenuCell_ID]; } cell.cellModel = dict; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ [tableView deselectRowAtIndexPath:indexPath animated:YES]; NSDictionary *dict = self.dataArr[indexPath.row]; SEL action = NSSelectorFromString(dict[@"sel"]); __strong id target = self.target; if (target && [target respondsToSelector:action]) { [self dismissVipMenuView]; [target performSelectorOnMainThread:action withObject:self waitUntilDone:YES]; } } #pragma mark - Show - (void)showVipMenuView//界面显示动画 { self.frame = CGRectMake(0.0, 0.0, SCREENWIDTH, SCREENHEIGHT); } - (void)dismissVipMenuView { [self removeFromSuperview]; } @end