├── Classes ├── IMYViewCache.h ├── IMYViewCache.m ├── IMYViewCacheManager.h ├── IMYViewCacheManager.m ├── IMYViewCacheRegisterInfo.h ├── IMYViewCacheRegisterInfo.m ├── UITableView+IMYViewCache.h └── UITableView+IMYViewCache.m ├── IMYViewCache.podspec.json ├── IMYViewCache.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── IMYViewCache ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Demo │ ├── IMYDemoVC.h │ ├── IMYDemoVC.m │ ├── IMYEBBrandSingleCell.h │ ├── IMYEBBrandSingleCell.m │ └── IMYEBBrandSingleCell.xib ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── LICENSE └── README.md /Classes/IMYViewCache.h: -------------------------------------------------------------------------------- 1 | // 2 | // IMYViewCache.h 3 | // IMYViewCache 4 | // 5 | // Created by ljh on 15/12/7. 6 | // Copyright © 2015年 IMY. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class IMYViewCacheRegisterInfo; 12 | ///请使用ViewCacheManager 来管理view的缓存 13 | NS_CLASS_DEPRECATED_IOS(1_0, 1_0, "IMYViewCache has been deprecated!") 14 | @interface IMYViewCache : NSObject 15 | 16 | @property (nonatomic, strong) IMYViewCacheRegisterInfo *viewInfo; 17 | @property (nonatomic, strong) NSMutableArray *cacheArray; 18 | ///每个viewCache加载的间隔 由manager提供 19 | @property (nonatomic, assign) double afterDelay; 20 | ///返回一个 view 实例 21 | - (id)getViewInstance; 22 | 23 | ///开始预加载 viewCache 24 | - (void)prepareLoadViewCache; 25 | - (void)willMoveToSuperview:(UIView *)newSuperview fromView:(UIView *)view; 26 | @end 27 | -------------------------------------------------------------------------------- /Classes/IMYViewCache.m: -------------------------------------------------------------------------------- 1 | // 2 | // IMYViewCache.m 3 | // IMYViewCache 4 | // 5 | // Created by ljh on 15/12/7. 6 | // Copyright © 2015年 IMY. All rights reserved. 7 | // 8 | 9 | #import "IMYViewCache.h" 10 | #import "IMYViewCacheRegisterInfo.h" 11 | 12 | @implementation IMYViewCache 13 | 14 | - (void)prepareLoadViewCache { 15 | } 16 | 17 | - (id)getViewInstance { 18 | return [self loadOneView]; 19 | } 20 | 21 | - (id)loadOneView { 22 | UIView *preloadView = nil; 23 | if (self.viewInfo.createViewBlock) { 24 | preloadView = self.viewInfo.createViewBlock(self.viewInfo); 25 | } 26 | 27 | if (!preloadView && self.viewInfo.nib) { 28 | Class viewClass = self.viewInfo.viewClass; 29 | NSArray *array = [self.viewInfo.nib instantiateWithOwner:nil options:nil]; 30 | for (UIView *subview in array) { 31 | if ([subview isKindOfClass:viewClass]) { 32 | preloadView = subview; 33 | break; 34 | } 35 | } 36 | } 37 | 38 | if (!preloadView) { 39 | Class viewClass = self.viewInfo.viewClass; 40 | preloadView = [[viewClass alloc] init]; 41 | } 42 | 43 | if ([preloadView respondsToSelector:@selector(prepareForInit)]) { 44 | [(id)preloadView prepareForInit]; 45 | } 46 | 47 | return preloadView; 48 | } 49 | 50 | - (void)willMoveToSuperview:(UIView *)newSuperview fromView:(UIView *)view { 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /Classes/IMYViewCacheManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // IMYViewCacheManager.h 3 | // IMYViewCache 4 | // 5 | // Created by ljh on 15/12/5. 6 | // Copyright © 2015年 IMY. All rights reserved. 7 | // 8 | 9 | #import "IMYViewCache.h" 10 | #import "IMYViewCacheRegisterInfo.h" 11 | #import 12 | 13 | NS_CLASS_DEPRECATED_IOS(1_0, 1_0, "IMYViewCache has been deprecated!") 14 | @interface IMYViewCacheManager : NSObject 15 | 16 | + (instancetype)shareInstance; 17 | 18 | @property (atomic, copy, readonly) NSArray *viewCachArray; 19 | 20 | - (IMYViewCacheRegisterInfo *)registerClass:(Class)viewClass; 21 | - (IMYViewCacheRegisterInfo *)registerClass:(Class)viewClass fromNib:(UINib *)nib; 22 | - (IMYViewCacheRegisterInfo *)registerClass:(Class)viewClass fromNib:(UINib *)nib reuseIdentifier:(NSString *)reuseIdentifier maxCount:(NSInteger)maxCount; 23 | 24 | - (void)registerViewInfo:(IMYViewCacheRegisterInfo *)info; 25 | 26 | - (id)instanceForClass:(Class)viewClass; 27 | - (id)instanceForClass:(Class)viewClass tableView:(UITableView *)tableView; 28 | - (id)instanceForClass:(Class)viewClass tableView:(UITableView *)tableView reuseIdentifier:(NSString *)reuseIdentifier; 29 | 30 | - (IMYViewCache *)getViewCacheForClass:(Class)viewClass reuseIdentifier:(NSString *)reuseIdentifier; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Classes/IMYViewCacheManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // IMYViewCacheManager.m 3 | // IMYViewCache 4 | // 5 | // Created by ljh on 15/12/5. 6 | // Copyright © 2015年 IMY. All rights reserved. 7 | // 8 | 9 | #import "IMYViewCacheManager.h" 10 | #import "IMYViewCache.h" 11 | 12 | @interface IMYViewCacheManager () 13 | @property (atomic, copy) NSArray *viewCachArray; 14 | @end 15 | 16 | @implementation IMYViewCacheManager 17 | 18 | + (instancetype)shareInstance { 19 | static id instance = nil; 20 | static dispatch_once_t onceToken; 21 | dispatch_once(&onceToken, ^{ 22 | instance = [self new]; 23 | }); 24 | return instance; 25 | } 26 | 27 | - (IMYViewCacheRegisterInfo *)registerClass:(Class)viewClass { 28 | IMYViewCacheRegisterInfo *info = [[IMYViewCacheRegisterInfo alloc] init]; 29 | info.viewClass = viewClass; 30 | NSString *viewString = NSStringFromClass(viewClass); 31 | NSString *xibPath = [[NSBundle mainBundle] pathForResource:viewString ofType:@"nib"]; 32 | if ([[NSFileManager defaultManager] fileExistsAtPath:xibPath]) { 33 | UINib *nib = [UINib nibWithNibName:viewString bundle:[NSBundle mainBundle]]; 34 | info.nib = nib; 35 | } 36 | [self registerViewInfo:info]; 37 | return info; 38 | } 39 | 40 | - (IMYViewCacheRegisterInfo *)registerClass:(Class)viewClass fromNib:(UINib *)nib { 41 | IMYViewCacheRegisterInfo *info = [[IMYViewCacheRegisterInfo alloc] init]; 42 | info.viewClass = viewClass; 43 | info.nib = nib; 44 | [self registerViewInfo:info]; 45 | return info; 46 | } 47 | 48 | - (IMYViewCacheRegisterInfo *)registerClass:(Class)viewClass fromNib:(UINib *)nib reuseIdentifier:(NSString *)reuseIdentifier maxCount:(NSInteger)maxCount { 49 | IMYViewCacheRegisterInfo *info = [[IMYViewCacheRegisterInfo alloc] init]; 50 | info.viewClass = viewClass; 51 | info.nib = nib; 52 | info.reuseIdentifier = reuseIdentifier; 53 | info.maxCount = maxCount; 54 | [self registerViewInfo:info]; 55 | return info; 56 | } 57 | 58 | - (IMYViewCache *)getViewCacheForClass:(Class)viewClass reuseIdentifier:(NSString *)reuseIdentifier { 59 | if (!viewClass && reuseIdentifier.length == 0) { 60 | return nil; 61 | } 62 | IMYViewCache *resultViewCache = nil; 63 | NSArray *array = self.viewCachArray; 64 | for (IMYViewCache *viewCache in array) { 65 | if (reuseIdentifier.length > 0 && [viewCache.viewInfo.reuseIdentifier isEqualToString:reuseIdentifier]) { 66 | resultViewCache = viewCache; 67 | break; 68 | } 69 | if (viewClass && viewCache.viewInfo.viewClass == viewClass) { 70 | resultViewCache = viewCache; 71 | break; 72 | } 73 | } 74 | return resultViewCache; 75 | } 76 | 77 | - (void)registerViewInfo:(IMYViewCacheRegisterInfo *)info { 78 | if (!info.viewClass) { 79 | NSAssert(NO, @"类形不能为空"); 80 | return; 81 | } 82 | IMYViewCache *viewCache = [self getViewCacheForClass:info.viewClass reuseIdentifier:info.reuseIdentifier]; 83 | if (viewCache) { 84 | NSAssert(NO, @"已经注册过该Class了"); 85 | return; 86 | } 87 | 88 | viewCache = [[IMYViewCache alloc] init]; 89 | viewCache.viewInfo = info; 90 | __block NSArray *oldArray = self.viewCachArray; 91 | NSMutableArray *mutableArray = [NSMutableArray arrayWithArray:oldArray]; 92 | [mutableArray addObject:viewCache]; 93 | self.viewCachArray = mutableArray; 94 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 95 | oldArray = nil; 96 | }); 97 | } 98 | 99 | - (id)instanceForClass:(Class)viewClass { 100 | IMYViewCache *viewCache = [self getViewCacheForClass:viewClass reuseIdentifier:nil]; 101 | id cell = [viewCache getViewInstance]; 102 | return cell; 103 | } 104 | 105 | - (id)instanceForClass:(Class)viewClass tableView:(UITableView *)tableView { 106 | IMYViewCache *viewCache = [self getViewCacheForClass:viewClass reuseIdentifier:nil]; 107 | id cell = [tableView dequeueReusableCellWithIdentifier:viewCache.viewInfo.reuseIdentifier]; 108 | if (cell) { 109 | return cell; 110 | } 111 | cell = [viewCache getViewInstance]; 112 | return cell; 113 | } 114 | 115 | - (id)instanceForClass:(Class)viewClass tableView:(UITableView *)tableView reuseIdentifier:(NSString *)reuseIdentifier { 116 | id cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier]; 117 | if (cell) { 118 | return cell; 119 | } 120 | IMYViewCache *viewCache = [self getViewCacheForClass:viewClass reuseIdentifier:reuseIdentifier]; 121 | cell = [viewCache getViewInstance]; 122 | return cell; 123 | } 124 | 125 | @end 126 | -------------------------------------------------------------------------------- /Classes/IMYViewCacheRegisterInfo.h: -------------------------------------------------------------------------------- 1 | // 2 | // IMYViewCacheRegisterInfo.h 3 | // IMYViewCache 4 | // 5 | // Created by ljh on 15/12/5. 6 | // Copyright © 2015年 IMY. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_CLASS_DEPRECATED_IOS(1_0, 1_0, "IMYViewCache has been deprecated!") 12 | @interface IMYViewCacheRegisterInfo : NSObject 13 | 14 | @property (nonatomic, strong) Class viewClass; /**< 需要缓存视图类*/ 15 | @property (nonatomic, strong) UINib *nib; /**< 从xib中加载缓存*/ 16 | @property (nonatomic, copy) NSString *reuseIdentifier; /**< 优先取tableView中的缓存*/ 17 | @property (nonatomic, assign) NSUInteger maxCount; /**< 内存中 最大的缓存数量*/ 18 | @property (nonatomic, assign) NSUInteger minCount; /**< 当收到内存警告时 最少的缓存保留数量 默认 0*/ 19 | 20 | @property (nonatomic, assign) double delay; /**< 注册后 延迟多少秒预加载 view*/ 21 | 22 | @property (nonatomic, copy) UIView * (^createViewBlock)(IMYViewCacheRegisterInfo *info); /**< 由外部进行UIView 的初始化*/ 23 | 24 | + (NSInteger)defaultCacheMaxCount; 25 | + (double)defaultPreloadingDelay; 26 | 27 | @end 28 | 29 | @protocol IMYViewCacheReuseProtocol 30 | ///初始化回调 31 | - (void)prepareForInit; 32 | ///复用回调 做些要复用的操作 33 | - (void)prepareForReuse; 34 | @end 35 | -------------------------------------------------------------------------------- /Classes/IMYViewCacheRegisterInfo.m: -------------------------------------------------------------------------------- 1 | // 2 | // IMYViewCacheRegisterInfo.m 3 | // IMYViewCache 4 | // 5 | // Created by ljh on 15/12/5. 6 | // Copyright © 2015年 IMY. All rights reserved. 7 | // 8 | 9 | #import "IMYViewCacheRegisterInfo.h" 10 | 11 | @implementation IMYViewCacheRegisterInfo 12 | 13 | - (instancetype)init { 14 | self = [super init]; 15 | if (self) { 16 | _delay = [IMYViewCacheRegisterInfo defaultPreloadingDelay]; 17 | } 18 | return self; 19 | } 20 | 21 | - (NSString *)reuseIdentifier { 22 | if (_reuseIdentifier == nil && _viewClass) { 23 | _reuseIdentifier = NSStringFromClass(_viewClass); 24 | } 25 | return _reuseIdentifier; 26 | } 27 | 28 | + (NSInteger)defaultCacheMaxCount { 29 | return 1; 30 | } 31 | 32 | + (double)defaultPreloadingDelay { 33 | return 10; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Classes/UITableView+IMYViewCache.h: -------------------------------------------------------------------------------- 1 | // 2 | // UITableView+IMYViewCache.h 3 | // IMYViewCache 4 | // 5 | // Created by ljh on 15/12/8. 6 | // Copyright © 2015年 IMY. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UITableView (IMYViewCache) 12 | 13 | ///如果设为YES 则 实例调用 dequeueReusable 也会走 IMYViewCache 的方法 14 | @property (nonatomic, assign) BOOL imy_usingViewCache __deprecated_msg("IMYViewCache has been deprecated!"); 15 | 16 | ///注册全局的 TableViewCell 17 | + (void)imy_registerClass:(Class)cellClass nib:(UINib *)nib reuseIdentifier:(NSString *)identifier cacheCount:(NSInteger)cacheCount __deprecated_msg("IMYViewCache has been deprecated!"); 18 | 19 | ///是否已经注册了全局cell cache 20 | + (BOOL)imy_hasRegistedClass:(Class)cellClass nib:(UINib *)nib reuseIdentifier:(NSString *)identifier __deprecated_msg("IMYViewCache has been deprecated!"); 21 | 22 | ///获取全局注册的 Cell 23 | + (UITableViewCell *)imy_dequeueReusableCellWithTableView:(UITableView *)tableView reuseIdentifier:(NSString *)identifier __deprecated_msg("IMYViewCache has been deprecated!"); 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Classes/UITableView+IMYViewCache.m: -------------------------------------------------------------------------------- 1 | // 2 | // UITableView+IMYViewCache.m 3 | // IMYViewCache 4 | // 5 | // Created by ljh on 15/12/8. 6 | // Copyright © 2015年 IMY. All rights reserved. 7 | // 8 | 9 | #import "IMYViewCacheManager.h" 10 | #import "UITableView+IMYViewCache.h" 11 | 12 | @implementation UITableView (IMYViewCache) 13 | 14 | - (BOOL)imy_usingViewCache { 15 | return NO; 16 | } 17 | 18 | - (void)setImy_usingViewCache:(BOOL)usingViewCache { 19 | if (!usingViewCache) { 20 | return; 21 | } 22 | NSArray *array = [IMYViewCacheManager shareInstance].viewCachArray; 23 | for (IMYViewCache *cache in array) { 24 | IMYViewCacheRegisterInfo *info = cache.viewInfo; 25 | if (!info.reuseIdentifier) { 26 | continue; 27 | } 28 | if (info.nib) { 29 | [self registerNib:info.nib forCellReuseIdentifier:info.reuseIdentifier]; 30 | } else { 31 | [self registerClass:info.viewClass forCellReuseIdentifier:info.reuseIdentifier]; 32 | } 33 | } 34 | } 35 | 36 | + (void)imy_registerClass:(Class)cellClass nib:(UINib *)nib reuseIdentifier:(NSString *)identifier cacheCount:(NSInteger)cacheCount { 37 | [[IMYViewCacheManager shareInstance] registerClass:cellClass fromNib:nib reuseIdentifier:identifier maxCount:cacheCount]; 38 | } 39 | 40 | + (BOOL)imy_hasRegistedClass:(Class)cellClass nib:(UINib *)nib reuseIdentifier:(NSString *)identifier { 41 | return ([[IMYViewCacheManager shareInstance] getViewCacheForClass:cellClass reuseIdentifier:identifier] != nil); 42 | } 43 | 44 | + (UITableViewCell *)imy_dequeueReusableCellWithTableView:(UITableView *)tableView reuseIdentifier:(NSString *)identifier { 45 | return [[IMYViewCacheManager shareInstance] instanceForClass:nil tableView:tableView reuseIdentifier:identifier]; 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /IMYViewCache.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "IMYViewCache", 3 | "version": "0.4", 4 | "summary": "Caching the UIView,speed up the UIView initialization", 5 | "description": "Caching the UIView,speed up the UIView initialization, UITableViewCell Optimize the most obvious", 6 | "homepage": "https://github.com/li6185377/IMYViewCache", 7 | "license": "MIT", 8 | "authors": { 9 | "Jianghuai Li": "li6185377@163.com" 10 | }, 11 | "source": { 12 | "git": "https://github.com/li6185377/IMYViewCache.git", 13 | "tag": "0.4" 14 | }, 15 | "platforms": { 16 | "ios": "5.0" 17 | }, 18 | "source_files": ["Classes/*.{h,m}"], 19 | "requires_arc": true, 20 | "deprecated": true 21 | } -------------------------------------------------------------------------------- /IMYViewCache.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 36E9B3AB1C15609900BAEBF4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 36E9B3AA1C15609900BAEBF4 /* main.m */; }; 11 | 36E9B3AE1C15609900BAEBF4 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 36E9B3AD1C15609900BAEBF4 /* AppDelegate.m */; }; 12 | 36E9B3B11C15609900BAEBF4 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 36E9B3B01C15609900BAEBF4 /* ViewController.m */; }; 13 | 36E9B3B41C15609900BAEBF4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 36E9B3B21C15609900BAEBF4 /* Main.storyboard */; }; 14 | 36E9B3B61C15609900BAEBF4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 36E9B3B51C15609900BAEBF4 /* Assets.xcassets */; }; 15 | 36E9B3B91C15609900BAEBF4 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 36E9B3B71C15609900BAEBF4 /* LaunchScreen.storyboard */; }; 16 | 36E9B3C71C1560E400BAEBF4 /* IMYViewCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 36E9B3C21C1560E400BAEBF4 /* IMYViewCache.m */; }; 17 | 36E9B3C81C1560E400BAEBF4 /* IMYViewCacheManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 36E9B3C41C1560E400BAEBF4 /* IMYViewCacheManager.m */; }; 18 | 36E9B3C91C1560E400BAEBF4 /* IMYViewCacheRegisterInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 36E9B3C61C1560E400BAEBF4 /* IMYViewCacheRegisterInfo.m */; }; 19 | 36E9B3CE1C15611B00BAEBF4 /* IMYEBBrandSingleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 36E9B3CC1C15611B00BAEBF4 /* IMYEBBrandSingleCell.m */; }; 20 | 36E9B3CF1C15611B00BAEBF4 /* IMYEBBrandSingleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 36E9B3CD1C15611B00BAEBF4 /* IMYEBBrandSingleCell.xib */; }; 21 | 36E9B3D21C1562B700BAEBF4 /* IMYDemoVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 36E9B3D11C1562B700BAEBF4 /* IMYDemoVC.m */; }; 22 | 36E9B3D51C166DEA00BAEBF4 /* UITableView+IMYViewCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 36E9B3D41C166DEA00BAEBF4 /* UITableView+IMYViewCache.m */; }; 23 | /* End PBXBuildFile section */ 24 | 25 | /* Begin PBXFileReference section */ 26 | 36E9B3A61C15609900BAEBF4 /* IMYViewCache.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = IMYViewCache.app; sourceTree = BUILT_PRODUCTS_DIR; }; 27 | 36E9B3AA1C15609900BAEBF4 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 28 | 36E9B3AC1C15609900BAEBF4 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 29 | 36E9B3AD1C15609900BAEBF4 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 30 | 36E9B3AF1C15609900BAEBF4 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 31 | 36E9B3B01C15609900BAEBF4 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 32 | 36E9B3B31C15609900BAEBF4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 33 | 36E9B3B51C15609900BAEBF4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 34 | 36E9B3B81C15609900BAEBF4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 35 | 36E9B3BA1C15609900BAEBF4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 36 | 36E9B3C11C1560E400BAEBF4 /* IMYViewCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IMYViewCache.h; sourceTree = ""; }; 37 | 36E9B3C21C1560E400BAEBF4 /* IMYViewCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IMYViewCache.m; sourceTree = ""; }; 38 | 36E9B3C31C1560E400BAEBF4 /* IMYViewCacheManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IMYViewCacheManager.h; sourceTree = ""; }; 39 | 36E9B3C41C1560E400BAEBF4 /* IMYViewCacheManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IMYViewCacheManager.m; sourceTree = ""; }; 40 | 36E9B3C51C1560E400BAEBF4 /* IMYViewCacheRegisterInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IMYViewCacheRegisterInfo.h; sourceTree = ""; }; 41 | 36E9B3C61C1560E400BAEBF4 /* IMYViewCacheRegisterInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IMYViewCacheRegisterInfo.m; sourceTree = ""; }; 42 | 36E9B3CB1C15611B00BAEBF4 /* IMYEBBrandSingleCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IMYEBBrandSingleCell.h; sourceTree = ""; }; 43 | 36E9B3CC1C15611B00BAEBF4 /* IMYEBBrandSingleCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IMYEBBrandSingleCell.m; sourceTree = ""; }; 44 | 36E9B3CD1C15611B00BAEBF4 /* IMYEBBrandSingleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = IMYEBBrandSingleCell.xib; sourceTree = ""; }; 45 | 36E9B3D01C1562B700BAEBF4 /* IMYDemoVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IMYDemoVC.h; sourceTree = ""; }; 46 | 36E9B3D11C1562B700BAEBF4 /* IMYDemoVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IMYDemoVC.m; sourceTree = ""; }; 47 | 36E9B3D31C166DEA00BAEBF4 /* UITableView+IMYViewCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UITableView+IMYViewCache.h"; sourceTree = ""; }; 48 | 36E9B3D41C166DEA00BAEBF4 /* UITableView+IMYViewCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UITableView+IMYViewCache.m"; sourceTree = ""; }; 49 | /* End PBXFileReference section */ 50 | 51 | /* Begin PBXFrameworksBuildPhase section */ 52 | 36E9B3A31C15609900BAEBF4 /* Frameworks */ = { 53 | isa = PBXFrameworksBuildPhase; 54 | buildActionMask = 2147483647; 55 | files = ( 56 | ); 57 | runOnlyForDeploymentPostprocessing = 0; 58 | }; 59 | /* End PBXFrameworksBuildPhase section */ 60 | 61 | /* Begin PBXGroup section */ 62 | 36E9B39D1C15609900BAEBF4 = { 63 | isa = PBXGroup; 64 | children = ( 65 | 36E9B3C01C1560E400BAEBF4 /* Classes */, 66 | 36E9B3A81C15609900BAEBF4 /* IMYViewCache */, 67 | 36E9B3A71C15609900BAEBF4 /* Products */, 68 | ); 69 | sourceTree = ""; 70 | }; 71 | 36E9B3A71C15609900BAEBF4 /* Products */ = { 72 | isa = PBXGroup; 73 | children = ( 74 | 36E9B3A61C15609900BAEBF4 /* IMYViewCache.app */, 75 | ); 76 | name = Products; 77 | sourceTree = ""; 78 | }; 79 | 36E9B3A81C15609900BAEBF4 /* IMYViewCache */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | 36E9B3CA1C15611B00BAEBF4 /* Demo */, 83 | 36E9B3AC1C15609900BAEBF4 /* AppDelegate.h */, 84 | 36E9B3AD1C15609900BAEBF4 /* AppDelegate.m */, 85 | 36E9B3AF1C15609900BAEBF4 /* ViewController.h */, 86 | 36E9B3B01C15609900BAEBF4 /* ViewController.m */, 87 | 36E9B3B21C15609900BAEBF4 /* Main.storyboard */, 88 | 36E9B3B51C15609900BAEBF4 /* Assets.xcassets */, 89 | 36E9B3B71C15609900BAEBF4 /* LaunchScreen.storyboard */, 90 | 36E9B3BA1C15609900BAEBF4 /* Info.plist */, 91 | 36E9B3A91C15609900BAEBF4 /* Supporting Files */, 92 | ); 93 | path = IMYViewCache; 94 | sourceTree = ""; 95 | }; 96 | 36E9B3A91C15609900BAEBF4 /* Supporting Files */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | 36E9B3AA1C15609900BAEBF4 /* main.m */, 100 | ); 101 | name = "Supporting Files"; 102 | sourceTree = ""; 103 | }; 104 | 36E9B3C01C1560E400BAEBF4 /* Classes */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | 36E9B3C11C1560E400BAEBF4 /* IMYViewCache.h */, 108 | 36E9B3C21C1560E400BAEBF4 /* IMYViewCache.m */, 109 | 36E9B3C31C1560E400BAEBF4 /* IMYViewCacheManager.h */, 110 | 36E9B3C41C1560E400BAEBF4 /* IMYViewCacheManager.m */, 111 | 36E9B3C51C1560E400BAEBF4 /* IMYViewCacheRegisterInfo.h */, 112 | 36E9B3C61C1560E400BAEBF4 /* IMYViewCacheRegisterInfo.m */, 113 | 36E9B3D31C166DEA00BAEBF4 /* UITableView+IMYViewCache.h */, 114 | 36E9B3D41C166DEA00BAEBF4 /* UITableView+IMYViewCache.m */, 115 | ); 116 | path = Classes; 117 | sourceTree = ""; 118 | }; 119 | 36E9B3CA1C15611B00BAEBF4 /* Demo */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | 36E9B3CB1C15611B00BAEBF4 /* IMYEBBrandSingleCell.h */, 123 | 36E9B3CC1C15611B00BAEBF4 /* IMYEBBrandSingleCell.m */, 124 | 36E9B3CD1C15611B00BAEBF4 /* IMYEBBrandSingleCell.xib */, 125 | 36E9B3D01C1562B700BAEBF4 /* IMYDemoVC.h */, 126 | 36E9B3D11C1562B700BAEBF4 /* IMYDemoVC.m */, 127 | ); 128 | path = Demo; 129 | sourceTree = ""; 130 | }; 131 | /* End PBXGroup section */ 132 | 133 | /* Begin PBXNativeTarget section */ 134 | 36E9B3A51C15609900BAEBF4 /* IMYViewCache */ = { 135 | isa = PBXNativeTarget; 136 | buildConfigurationList = 36E9B3BD1C15609900BAEBF4 /* Build configuration list for PBXNativeTarget "IMYViewCache" */; 137 | buildPhases = ( 138 | 36E9B3A21C15609900BAEBF4 /* Sources */, 139 | 36E9B3A31C15609900BAEBF4 /* Frameworks */, 140 | 36E9B3A41C15609900BAEBF4 /* Resources */, 141 | ); 142 | buildRules = ( 143 | ); 144 | dependencies = ( 145 | ); 146 | name = IMYViewCache; 147 | productName = IMYViewCache; 148 | productReference = 36E9B3A61C15609900BAEBF4 /* IMYViewCache.app */; 149 | productType = "com.apple.product-type.application"; 150 | }; 151 | /* End PBXNativeTarget section */ 152 | 153 | /* Begin PBXProject section */ 154 | 36E9B39E1C15609900BAEBF4 /* Project object */ = { 155 | isa = PBXProject; 156 | attributes = { 157 | LastUpgradeCheck = 0710; 158 | ORGANIZATIONNAME = IMY; 159 | TargetAttributes = { 160 | 36E9B3A51C15609900BAEBF4 = { 161 | CreatedOnToolsVersion = 7.1.1; 162 | }; 163 | }; 164 | }; 165 | buildConfigurationList = 36E9B3A11C15609900BAEBF4 /* Build configuration list for PBXProject "IMYViewCache" */; 166 | compatibilityVersion = "Xcode 3.2"; 167 | developmentRegion = English; 168 | hasScannedForEncodings = 0; 169 | knownRegions = ( 170 | en, 171 | Base, 172 | ); 173 | mainGroup = 36E9B39D1C15609900BAEBF4; 174 | productRefGroup = 36E9B3A71C15609900BAEBF4 /* Products */; 175 | projectDirPath = ""; 176 | projectRoot = ""; 177 | targets = ( 178 | 36E9B3A51C15609900BAEBF4 /* IMYViewCache */, 179 | ); 180 | }; 181 | /* End PBXProject section */ 182 | 183 | /* Begin PBXResourcesBuildPhase section */ 184 | 36E9B3A41C15609900BAEBF4 /* Resources */ = { 185 | isa = PBXResourcesBuildPhase; 186 | buildActionMask = 2147483647; 187 | files = ( 188 | 36E9B3CF1C15611B00BAEBF4 /* IMYEBBrandSingleCell.xib in Resources */, 189 | 36E9B3B91C15609900BAEBF4 /* LaunchScreen.storyboard in Resources */, 190 | 36E9B3B61C15609900BAEBF4 /* Assets.xcassets in Resources */, 191 | 36E9B3B41C15609900BAEBF4 /* Main.storyboard in Resources */, 192 | ); 193 | runOnlyForDeploymentPostprocessing = 0; 194 | }; 195 | /* End PBXResourcesBuildPhase section */ 196 | 197 | /* Begin PBXSourcesBuildPhase section */ 198 | 36E9B3A21C15609900BAEBF4 /* Sources */ = { 199 | isa = PBXSourcesBuildPhase; 200 | buildActionMask = 2147483647; 201 | files = ( 202 | 36E9B3C91C1560E400BAEBF4 /* IMYViewCacheRegisterInfo.m in Sources */, 203 | 36E9B3B11C15609900BAEBF4 /* ViewController.m in Sources */, 204 | 36E9B3AE1C15609900BAEBF4 /* AppDelegate.m in Sources */, 205 | 36E9B3D21C1562B700BAEBF4 /* IMYDemoVC.m in Sources */, 206 | 36E9B3D51C166DEA00BAEBF4 /* UITableView+IMYViewCache.m in Sources */, 207 | 36E9B3AB1C15609900BAEBF4 /* main.m in Sources */, 208 | 36E9B3C71C1560E400BAEBF4 /* IMYViewCache.m in Sources */, 209 | 36E9B3CE1C15611B00BAEBF4 /* IMYEBBrandSingleCell.m in Sources */, 210 | 36E9B3C81C1560E400BAEBF4 /* IMYViewCacheManager.m in Sources */, 211 | ); 212 | runOnlyForDeploymentPostprocessing = 0; 213 | }; 214 | /* End PBXSourcesBuildPhase section */ 215 | 216 | /* Begin PBXVariantGroup section */ 217 | 36E9B3B21C15609900BAEBF4 /* Main.storyboard */ = { 218 | isa = PBXVariantGroup; 219 | children = ( 220 | 36E9B3B31C15609900BAEBF4 /* Base */, 221 | ); 222 | name = Main.storyboard; 223 | sourceTree = ""; 224 | }; 225 | 36E9B3B71C15609900BAEBF4 /* LaunchScreen.storyboard */ = { 226 | isa = PBXVariantGroup; 227 | children = ( 228 | 36E9B3B81C15609900BAEBF4 /* Base */, 229 | ); 230 | name = LaunchScreen.storyboard; 231 | sourceTree = ""; 232 | }; 233 | /* End PBXVariantGroup section */ 234 | 235 | /* Begin XCBuildConfiguration section */ 236 | 36E9B3BB1C15609900BAEBF4 /* Debug */ = { 237 | isa = XCBuildConfiguration; 238 | buildSettings = { 239 | ALWAYS_SEARCH_USER_PATHS = NO; 240 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 241 | CLANG_CXX_LIBRARY = "libc++"; 242 | CLANG_ENABLE_MODULES = YES; 243 | CLANG_ENABLE_OBJC_ARC = YES; 244 | CLANG_WARN_BOOL_CONVERSION = YES; 245 | CLANG_WARN_CONSTANT_CONVERSION = YES; 246 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 247 | CLANG_WARN_EMPTY_BODY = YES; 248 | CLANG_WARN_ENUM_CONVERSION = YES; 249 | CLANG_WARN_INT_CONVERSION = YES; 250 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 251 | CLANG_WARN_UNREACHABLE_CODE = YES; 252 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 253 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 254 | COPY_PHASE_STRIP = NO; 255 | DEBUG_INFORMATION_FORMAT = dwarf; 256 | ENABLE_STRICT_OBJC_MSGSEND = YES; 257 | ENABLE_TESTABILITY = YES; 258 | GCC_C_LANGUAGE_STANDARD = gnu99; 259 | GCC_DYNAMIC_NO_PIC = NO; 260 | GCC_NO_COMMON_BLOCKS = YES; 261 | GCC_OPTIMIZATION_LEVEL = 0; 262 | GCC_PREPROCESSOR_DEFINITIONS = ( 263 | "DEBUG=1", 264 | "$(inherited)", 265 | ); 266 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 267 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 268 | GCC_WARN_UNDECLARED_SELECTOR = YES; 269 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 270 | GCC_WARN_UNUSED_FUNCTION = YES; 271 | GCC_WARN_UNUSED_VARIABLE = YES; 272 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 273 | MTL_ENABLE_DEBUG_INFO = YES; 274 | ONLY_ACTIVE_ARCH = YES; 275 | SDKROOT = iphoneos; 276 | }; 277 | name = Debug; 278 | }; 279 | 36E9B3BC1C15609900BAEBF4 /* Release */ = { 280 | isa = XCBuildConfiguration; 281 | buildSettings = { 282 | ALWAYS_SEARCH_USER_PATHS = NO; 283 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 284 | CLANG_CXX_LIBRARY = "libc++"; 285 | CLANG_ENABLE_MODULES = YES; 286 | CLANG_ENABLE_OBJC_ARC = YES; 287 | CLANG_WARN_BOOL_CONVERSION = YES; 288 | CLANG_WARN_CONSTANT_CONVERSION = YES; 289 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 290 | CLANG_WARN_EMPTY_BODY = YES; 291 | CLANG_WARN_ENUM_CONVERSION = YES; 292 | CLANG_WARN_INT_CONVERSION = YES; 293 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 294 | CLANG_WARN_UNREACHABLE_CODE = YES; 295 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 296 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 297 | COPY_PHASE_STRIP = NO; 298 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 299 | ENABLE_NS_ASSERTIONS = NO; 300 | ENABLE_STRICT_OBJC_MSGSEND = YES; 301 | GCC_C_LANGUAGE_STANDARD = gnu99; 302 | GCC_NO_COMMON_BLOCKS = YES; 303 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 304 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 305 | GCC_WARN_UNDECLARED_SELECTOR = YES; 306 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 307 | GCC_WARN_UNUSED_FUNCTION = YES; 308 | GCC_WARN_UNUSED_VARIABLE = YES; 309 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 310 | MTL_ENABLE_DEBUG_INFO = NO; 311 | SDKROOT = iphoneos; 312 | VALIDATE_PRODUCT = YES; 313 | }; 314 | name = Release; 315 | }; 316 | 36E9B3BE1C15609900BAEBF4 /* Debug */ = { 317 | isa = XCBuildConfiguration; 318 | buildSettings = { 319 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 320 | INFOPLIST_FILE = IMYViewCache/Info.plist; 321 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 322 | PRODUCT_BUNDLE_IDENTIFIER = IMY.IMYViewCache; 323 | PRODUCT_NAME = "$(TARGET_NAME)"; 324 | }; 325 | name = Debug; 326 | }; 327 | 36E9B3BF1C15609900BAEBF4 /* Release */ = { 328 | isa = XCBuildConfiguration; 329 | buildSettings = { 330 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 331 | INFOPLIST_FILE = IMYViewCache/Info.plist; 332 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 333 | PRODUCT_BUNDLE_IDENTIFIER = IMY.IMYViewCache; 334 | PRODUCT_NAME = "$(TARGET_NAME)"; 335 | }; 336 | name = Release; 337 | }; 338 | /* End XCBuildConfiguration section */ 339 | 340 | /* Begin XCConfigurationList section */ 341 | 36E9B3A11C15609900BAEBF4 /* Build configuration list for PBXProject "IMYViewCache" */ = { 342 | isa = XCConfigurationList; 343 | buildConfigurations = ( 344 | 36E9B3BB1C15609900BAEBF4 /* Debug */, 345 | 36E9B3BC1C15609900BAEBF4 /* Release */, 346 | ); 347 | defaultConfigurationIsVisible = 0; 348 | defaultConfigurationName = Release; 349 | }; 350 | 36E9B3BD1C15609900BAEBF4 /* Build configuration list for PBXNativeTarget "IMYViewCache" */ = { 351 | isa = XCConfigurationList; 352 | buildConfigurations = ( 353 | 36E9B3BE1C15609900BAEBF4 /* Debug */, 354 | 36E9B3BF1C15609900BAEBF4 /* Release */, 355 | ); 356 | defaultConfigurationIsVisible = 0; 357 | defaultConfigurationName = Release; 358 | }; 359 | /* End XCConfigurationList section */ 360 | }; 361 | rootObject = 36E9B39E1C15609900BAEBF4 /* Project object */; 362 | } 363 | -------------------------------------------------------------------------------- /IMYViewCache.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /IMYViewCache/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // IMYViewCache 4 | // 5 | // Created by ljh on 15/12/7. 6 | // Copyright © 2015年 IMY. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (nonatomic, strong) UIWindow *window; 14 | 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /IMYViewCache/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // IMYViewCache 4 | // 5 | // Created by ljh on 15/12/7. 6 | // Copyright © 2015年 IMY. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /IMYViewCache/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /IMYViewCache/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /IMYViewCache/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 30 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /IMYViewCache/Demo/IMYDemoVC.h: -------------------------------------------------------------------------------- 1 | // 2 | // IMYDemoVC.h 3 | // IMYViewCache 4 | // 5 | // Created by ljh on 15/12/7. 6 | // Copyright © 2015年 IMY. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface IMYDemoVC : UIViewController 12 | @property BOOL isUsingCache; 13 | @end 14 | -------------------------------------------------------------------------------- /IMYViewCache/Demo/IMYDemoVC.m: -------------------------------------------------------------------------------- 1 | // 2 | // IMYDemoVC.m 3 | // IMYViewCache 4 | // 5 | // Created by ljh on 15/12/7. 6 | // Copyright © 2015年 IMY. All rights reserved. 7 | // 8 | 9 | #import "IMYDemoVC.h" 10 | #import "IMYEBBrandSingleCell.h" 11 | #import "IMYViewCacheManager.h" 12 | #import "UITableView+IMYViewCache.h" 13 | 14 | @interface IMYDemoVC () 15 | 16 | @end 17 | 18 | @implementation IMYDemoVC 19 | + (void)load { 20 | ///max count = 0 会自动计算 一屏幕高度下 可以放多少个cell 21 | [UITableView imy_registerClass:[IMYEBBrandSingleCell class] nib:[UINib nibWithNibName:@"IMYEBBrandSingleCell" bundle:nil] reuseIdentifier:@"IMYEBBrandSingleCell" cacheCount:8]; 22 | } 23 | - (void)viewDidLoad { 24 | [super viewDidLoad]; 25 | UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; 26 | tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 27 | tableView.delegate = self; 28 | tableView.dataSource = self; 29 | tableView.imy_usingViewCache = _isUsingCache; 30 | [self.view addSubview:tableView]; 31 | 32 | if (_isUsingCache == NO) { 33 | [tableView registerNib:[UINib nibWithNibName:@"IMYEBBrandSingleCell" bundle:nil] forCellReuseIdentifier:@"IMYEBBrandSingleCell"]; 34 | } else { 35 | tableView.imy_usingViewCache = YES; 36 | } 37 | } 38 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 39 | return 100; 40 | } 41 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 42 | NSTimeInterval startLoadTime = [[NSDate date] timeIntervalSince1970]; 43 | IMYEBBrandSingleCell *cell = [tableView dequeueReusableCellWithIdentifier:@"IMYEBBrandSingleCell"]; 44 | cell.titleLabel.text = [NSString stringWithFormat:@"%@", indexPath]; 45 | NSTimeInterval endTime = [[NSDate date] timeIntervalSince1970]; 46 | NSLog(@"cell %@ ,加载时间:%lf", indexPath, endTime - startLoadTime); 47 | 48 | return cell; 49 | } 50 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 51 | return [IMYEBBrandSingleCell cellHeight]; 52 | } 53 | @end 54 | -------------------------------------------------------------------------------- /IMYViewCache/Demo/IMYEBBrandSingleCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // IMYEBBrandSingleCell.h 3 | // IMY_EBusiness 4 | // 5 | // Created by ljh on 15/5/22. 6 | // Copyright (c) 2015年 IMY. All rights reserved. 7 | // 8 | 9 | #import "IMYViewCacheManager.h" 10 | #import 11 | 12 | @interface IMYEBBrandSingleCell : UITableViewCell 13 | 14 | @property (weak, nonatomic) IBOutlet UILabel *discountLabel; 15 | @property (weak, nonatomic) IBOutlet UILabel *titleLabel; 16 | @property (weak, nonatomic) IBOutlet UILabel *rightTitleLabel; 17 | 18 | @property (weak, nonatomic) IBOutlet UIButton *moodsButton; 19 | @property (weak, nonatomic) IBOutlet UIImageView *contentImageView; 20 | 21 | @property (weak, nonatomic) IBOutlet UIImageView *custonTagImageView; 22 | @property (weak, nonatomic) IBOutlet UILabel *customTagLabel; 23 | 24 | @property (weak, nonatomic) IBOutlet NSLayoutConstraint *leftTitleLayoutConstraint; 25 | 26 | + (CGFloat)cellHeight; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /IMYViewCache/Demo/IMYEBBrandSingleCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // IMYEBBrandSingleCell.m 3 | // IMY_EBusiness 4 | // 5 | // Created by ljh on 15/5/22. 6 | // Copyright (c) 2015年 IMY. All rights reserved. 7 | // 8 | 9 | #import "IMYEBBrandSingleCell.h" 10 | 11 | @interface IMYEBBrandSingleCell () 12 | @end 13 | 14 | @implementation IMYEBBrandSingleCell 15 | ///初始化回调 16 | - (void)prepareForInit { 17 | self.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [IMYEBBrandSingleCell cellHeight]); 18 | } 19 | ///复用回调 20 | - (void)prepareForReuse { 21 | [super prepareForReuse]; 22 | ///没啥事干 23 | ///如果是 cell 一定要调用 super 24 | ///you must be sure to invoke the superclass implementation. 25 | } 26 | 27 | 28 | + (CGFloat)cellHeight { 29 | return ceil(47 + 148 * ([UIScreen mainScreen].bounds.size.width / 320.0f)); 30 | } 31 | @end 32 | -------------------------------------------------------------------------------- /IMYViewCache/Demo/IMYEBBrandSingleCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 37 | 43 | 49 | 55 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /IMYViewCache/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /IMYViewCache/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // IMYViewCache 4 | // 5 | // Created by ljh on 15/12/7. 6 | // Copyright © 2015年 IMY. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /IMYViewCache/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // IMYViewCache 4 | // 5 | // Created by ljh on 15/12/7. 6 | // Copyright © 2015年 IMY. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "IMYDemoVC.h" 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view, typically from a nib. 20 | } 21 | 22 | - (void)didReceiveMemoryWarning { 23 | [super didReceiveMemoryWarning]; 24 | // Dispose of any resources that can be recreated. 25 | } 26 | - (IBAction)bt_action_nocache:(id)sender { 27 | IMYDemoVC *vc = [[IMYDemoVC alloc] init]; 28 | [self.navigationController pushViewController:vc animated:YES]; 29 | } 30 | - (IBAction)bt_action_usingCache:(id)sender { 31 | IMYDemoVC *vc = [[IMYDemoVC alloc] init]; 32 | vc.isUsingCache = YES; 33 | [self.navigationController pushViewController:vc animated:YES]; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /IMYViewCache/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // IMYViewCache 4 | // 5 | // Created by ljh on 15/12/7. 6 | // Copyright © 2015年 IMY. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import 11 | 12 | int main(int argc, char *argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Jianghuai Li (https://github.com/li6185377) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IMYViewCache 2 | 3 | 对View进行缓存 预加载UIView,提高界面切换速度。 支持全局UITableViewCell复用 4 | 5 | 使用 5s 测试 6 | 7 | no_cache 加载时间:0.002630 8 | no_cache 加载时间:0.001345 9 | no_cache 加载时间:0.001508 10 | 11 | cache 加载时间:0.000082 12 | cache 加载时间:0.000048 13 | cache 加载时间:0.000042 14 | 15 | 差不多会差10倍 16 | 17 | 4s 测试 18 | 19 | no_cache 加载时间:0.007064 20 | no_cache 加载时间:0.006878 21 | no_cache 加载时间:0.006625 22 | 23 | cache 加载时间:0.000315 24 | cache 加载时间:0.000338 25 | cache 加载时间:0.000314 26 | 27 | 虽然 0.001 的单位。 肉眼是感觉不出来的 但是如果界面一旦复杂起来,cell数量一多,机型更破 优化的效果会更明显 28 | 29 | ------------------------------------ 30 | 31 | ## Requirements 32 | * iOS 5.0+ 33 | * ARC only 34 | 35 | ## Adding to your project 36 | 37 | pod 'IMYViewCache', :head 38 | 39 | ## Basic usage 40 | 41 | 1 . use `IMYViewCacheManager` register view class 42 | 43 | ```objective-c 44 | +(void)load 45 | { 46 | [UITableView imy_registerClass:[IMYEBBrandSingleCell class] nib:[UINib nibWithNibName:@"IMYEBBrandSingleCell" bundle:nil] reuseIdentifier:@"IMYEBBrandSingleCell" cacheCount:8]; 47 | } 48 | and 49 | UITableView *tableView = [new]; 50 | ... 51 | tableView.imy_usingViewCache = YES; 52 | ``` 53 | 54 | 2 . replace view initialization method 55 | 56 | ```objective-c 57 | IMYEBBrandSingleCell* cell = [tableView dequeueReusableCellWithIdentifier:@"IMYEBBrandSingleCell"]; 58 | ``` 59 | 60 | 3 . OK 61 | 62 | 63 | 64 | --------------------------------------------------------------------------------