From 7b02207537d35bfa1714bf8beafc921f717d100a Mon Sep 17 00:00:00 2001 From: 单军华 Date: Wed, 11 Jul 2018 10:47:42 +0800 Subject: [PATCH] 首次上传 --- screendisplay/screendisplay/Classes/Base/BaseControllers/LMJStaticTableViewController.m | 126 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 126 insertions(+), 0 deletions(-) diff --git a/screendisplay/screendisplay/Classes/Base/BaseControllers/LMJStaticTableViewController.m b/screendisplay/screendisplay/Classes/Base/BaseControllers/LMJStaticTableViewController.m new file mode 100755 index 0000000..05483a7 --- /dev/null +++ b/screendisplay/screendisplay/Classes/Base/BaseControllers/LMJStaticTableViewController.m @@ -0,0 +1,126 @@ +// +// LMJBaseSettingViewController.m +// NetLottery +// +// Created by apple on 16/6/23. +// Copyright �� 2016��� 163. All rights reserved. +// + +#import "LMJStaticTableViewController.h" +#import "LMJSettingCell.h" + +const UIEdgeInsets tableViewDefaultSeparatorInset = {0, 15, 0, 0}; +const UIEdgeInsets tableViewDefaultLayoutMargins = {8, 8, 8, 8}; + +@interface LMJStaticTableViewController () + +@end + +@implementation LMJStaticTableViewController + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + NSLog(@"self.tableView.separatorInset = %@, self.tableView.separatorInset = %@", NSStringFromUIEdgeInsets(self.tableView.separatorInset), NSStringFromUIEdgeInsets(self.tableView.layoutMargins)); + // self.tableView.separatorInset = UIEdgeInsetsZero; + // self.tableView.layoutMargins = UIEdgeInsetsZero; +} + + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return self.sections.count; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + return self.sections[section].items.count; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + LMJWordItem *item = self.sections[indexPath.section].items[indexPath.row]; + + + LMJSettingCell *cell = [LMJSettingCell cellWithTableView:tableView andCellStyle:UITableViewCellStyleValue1]; + + cell.item = item; + + return cell; +} + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + + LMJWordItem *item = self.sections[indexPath.section].items[indexPath.row]; + + // ���������cell + if(item.itemOperation) + { + item.itemOperation(indexPath); + return; + } + + // ������������cell + if([item isKindOfClass:[LMJWordArrowItem class]]) + { + LMJWordArrowItem *arrowItem = (LMJWordArrowItem *)item; + + if(arrowItem.destVc) + { + UIViewController *vc = [[arrowItem.destVc alloc] init]; + if ([vc isKindOfClass:[UIViewController class]]) { + vc.navigationItem.title = arrowItem.title; + [self.navigationController pushViewController:vc animated:YES]; + } + } + } + + +} + +- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section +{ + return self.sections[section].headerTitle; +} + +- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section +{ + return self.sections[section].footerTitle; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath +{ + return self.sections[indexPath.section].items[indexPath.row].cellHeight; +} + +- (NSMutableArray<LMJItemSection *> *)sections +{ + if(_sections == nil) + { + _sections = [NSMutableArray array]; + } + return _sections; +} + +- (LMJStaticTableViewController *(^)(LMJWordItem *))addItem { + + TWWeak(self); + if (!self.sections.firstObject) { + [self.sections addObject:[LMJItemSection sectionWithItems:@[] andHeaderTitle:nil footerTitle:nil]]; + } + return ^(LMJWordItem *item) { + [weakself.sections.firstObject.items addObject:item]; + return weakself; + }; +} + +- (instancetype)init +{ + return [super initWithStyle:UITableViewStyleGrouped]; +} + + +@end -- Gitblit v1.8.0