Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
hoaye committed Nov 30, 2020
1 parent 0dd21fd commit 8b35ced
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 43 deletions.
3 changes: 1 addition & 2 deletions ElegantTableView.podspec
@@ -1,4 +1,4 @@
version = "0.0.3";
version = "0.0.4";

Pod::Spec.new do |s|

Expand All @@ -17,4 +17,3 @@ Pod::Spec.new do |s|
s.requires_arc = true

end

9 changes: 4 additions & 5 deletions ElegantTableView/ElegantTableViewGenerator.h
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2017年 houmanager. All rights reserved.
// 优雅的 创建简单的 TableView

/** 当前版本: 0.0.3 */
/** 当前版本: 0.0.4 */

#import <UIKit/UIKit.h>

Expand All @@ -15,11 +15,10 @@ typedef void(^didScrollHandleBlock)(UIScrollView *tableView, CGPoint contentOffs

@interface ElegantTableViewGenerator : NSObject

/** 单例 */
+ (ElegantTableViewGenerator *)shareInstance;
@property (nonatomic, strong) UITableView *tableView;

/** 创建tableView */
- (UITableView *)createWithFrame:(CGRect)frame
/** 创建tableView生成器 */
+ (ElegantTableViewGenerator *)createWithFrame:(CGRect)frame
titles:(NSArray *)titles
subTitles:(NSArray *)subTitles
rowHeight:(CGFloat)rowHeight
Expand Down
34 changes: 16 additions & 18 deletions ElegantTableView/ElegantTableViewGenerator.m
Expand Up @@ -19,36 +19,30 @@ @interface ElegantTableViewGenerator () <UITableViewDelegate, UITableViewDataSou

@implementation ElegantTableViewGenerator

+ (ElegantTableViewGenerator *)shareInstance{
static ElegantTableViewGenerator *_instance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_instance = [[ElegantTableViewGenerator alloc] init];
});
return _instance;
}

- (UITableView *)createWithFrame:(CGRect)frame
+ (ElegantTableViewGenerator *)createWithFrame:(CGRect)frame
titles:(NSArray *)titles
subTitles:(NSArray *)subTitles
rowHeight:(CGFloat)rowHeight
didSelectRowBlock:(didSelectRowHandleBlock)didSelectRowBlock
didScrollBlock:(didScrollHandleBlock)didScrollBlock{
didScrollBlock:(didScrollHandleBlock)didScrollBlock {

ElegantTableViewGenerator *tableViewGenerator = [[ElegantTableViewGenerator alloc] init];

self.titles = [NSMutableArray arrayWithArray:titles];
self.subTitles = [NSMutableArray arrayWithArray:subTitles];
self.didselectRowBlock = didSelectRowBlock;
self.didScrollBlock = didScrollBlock;
tableViewGenerator.titles = [NSMutableArray arrayWithArray:titles];
tableViewGenerator.subTitles = [NSMutableArray arrayWithArray:subTitles];
tableViewGenerator.didselectRowBlock = didSelectRowBlock;
tableViewGenerator.didScrollBlock = didScrollBlock;

UITableView *tableView = [[UITableView alloc] initWithFrame:frame style:UITableViewStylePlain];
tableView.delegate = self;
tableView.dataSource = self;
tableView.delegate = tableViewGenerator;
tableView.dataSource = tableViewGenerator;
tableView.rowHeight = rowHeight;
tableView.tableFooterView = [UIView new];

tableView.estimatedSectionHeaderHeight = tableView.estimatedSectionFooterHeight = tableView.estimatedRowHeight = 0.0f;
tableViewGenerator.tableView = tableView;

return tableView;
return tableViewGenerator;
}

#pragma mark - UITableViewDataSource
Expand Down Expand Up @@ -106,4 +100,8 @@ - (NSMutableArray *)subTitles{
return _subTitles;
}

- (void)dealloc {
// NSLog(@"-->%s", __func__);
}

@end
12 changes: 7 additions & 5 deletions ElegantTableViewDemo.xcodeproj/project.pbxproj
Expand Up @@ -204,7 +204,7 @@
TargetAttributes = {
6307D6F51F09F55200CF1EAD = {
CreatedOnToolsVersion = 8.3.3;
DevelopmentTeam = 33K3DU6932;
DevelopmentTeam = 53U7T4TFCY;
ProvisioningStyle = Automatic;
};
6307D7181F0A0BF100CF1EAD = {
Expand All @@ -219,6 +219,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -398,11 +399,11 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 33K3DU6932;
DEVELOPMENT_TEAM = 53U7T4TFCY;
INFOPLIST_FILE = ElegantTableViewDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.houmanager.de;
PRODUCT_BUNDLE_IDENTIFIER = com.mk.demo;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
};
Expand All @@ -413,11 +414,11 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 33K3DU6932;
DEVELOPMENT_TEAM = 53U7T4TFCY;
INFOPLIST_FILE = ElegantTableViewDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.houmanager.de;
PRODUCT_BUNDLE_IDENTIFIER = com.mk.demo;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
};
Expand Down Expand Up @@ -501,6 +502,7 @@
6307D7241F0A0BF100CF1EAD /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
2 changes: 1 addition & 1 deletion ElegantTableViewDemo/AppDelegate.h
Expand Up @@ -3,7 +3,7 @@
// ElegantTableViewDemo
//
// Created by YJHou on 2017/7/3.
// Copyright © 2017年 侯跃军. All rights reserved.
// Copyright © 2017年 MonkeyKing. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
2 changes: 1 addition & 1 deletion ElegantTableViewDemo/AppDelegate.m
Expand Up @@ -3,7 +3,7 @@
// ElegantTableViewDemo
//
// Created by YJHou on 2017/7/3.
// Copyright © 2017年 侯跃军. All rights reserved.
// Copyright © 2017年 MonkeyKing. All rights reserved.
//

#import "AppDelegate.h"
Expand Down
32 changes: 27 additions & 5 deletions ElegantTableViewDemo/Base.lproj/Main.storyboard
@@ -1,26 +1,48 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="lHU-FP-r5Z">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17126"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
<viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<navigationItem key="navigationItem" id="0k9-i8-e0D"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1039.1304347826087" y="46.875"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="mcd-wV-bHb">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="lHU-FP-r5Z" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="iyf-g2-2yk">
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="rrP-Op-DGz"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="OJM-tG-TGu" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="128.98550724637681" y="46.875"/>
</scene>
</scenes>
</document>
2 changes: 1 addition & 1 deletion ElegantTableViewDemo/ViewController.h
Expand Up @@ -3,7 +3,7 @@
// ElegantTableViewDemo
//
// Created by YJHou on 2017/7/3.
// Copyright © 2017年 侯跃军. All rights reserved.
// Copyright © 2017年 MonkeyKing. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
10 changes: 7 additions & 3 deletions ElegantTableViewDemo/ViewController.m
Expand Up @@ -3,30 +3,34 @@
// ElegantTableViewDemo
//
// Created by YJHou on 2017/7/3.
// Copyright © 2017年 侯跃军. All rights reserved.
// Copyright © 2017年 MonkeyKing. All rights reserved.
//

#import "ViewController.h"
#import "ElegantTableViewGenerator.h"

@interface ViewController ()

@property (nonatomic, strong) ElegantTableViewGenerator *tableViewGenerator;

@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];

self.title = @"创建简单的TableView";


NSArray *dataSources = @[@"", @"", @"", @"1", @"2", @"3"];
UITableView *tableView = [[ElegantTableViewGenerator shareInstance] createWithFrame:self.view.bounds titles:dataSources subTitles:nil rowHeight:44 didSelectRowBlock:^(UITableView *tableView, NSIndexPath *indexPath) {
self.tableViewGenerator = [ElegantTableViewGenerator createWithFrame:self.view.bounds titles:dataSources subTitles:nil rowHeight:44 didSelectRowBlock:^(UITableView *tableView, NSIndexPath *indexPath) {
NSLog(@"点击TableView-->%ld", (long)indexPath.row);
} didScrollBlock:^(UIScrollView *tableView, CGPoint contentOffset) {
NSLog(@"滚动TableView-->%@", NSStringFromCGPoint(contentOffset));
}];

[self.view addSubview:tableView];
[self.view addSubview:self.tableViewGenerator.tableView];
}


Expand Down
2 changes: 1 addition & 1 deletion ElegantTableViewDemo/main.m
Expand Up @@ -3,7 +3,7 @@
// ElegantTableViewDemo
//
// Created by YJHou on 2017/7/3.
// Copyright © 2017年 侯跃军. All rights reserved.
// Copyright © 2017年 MonkeyKing. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
2 changes: 1 addition & 1 deletion ElegantTableViewFramework/ElegantTableViewFramework.h
Expand Up @@ -3,7 +3,7 @@
// ElegantTableViewFramework
//
// Created by YJHou on 2017/7/3.
// Copyright © 2017年 侯跃军. All rights reserved.
// Copyright © 2017年 MonkeyKing. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down

0 comments on commit 8b35ced

Please sign in to comment.