- (float)checkTmpSize
{
float totalSize = 0;
NSDirectoryEnumerator *fileEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:_diskCachePath];
for (NSString *fileName in fileEnumerator)
{
NSString *filePath = [_diskCachePath stringByAppendingPathComponent:fileName];
NSDictionary *attrs = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil];
unsigned long long length = [attrs fileSize];
totalSize += length / 1024.0 / 1024.0;
}
// NSLog(@"tmp size is %.2f",totalSize);
return totalSize;
}
#import "BaseViewController.h"
#import "More.h"
@interface MoreViewController : BaseViewController<UITableViewDataSource,UITableViewDelegate>
@property(strong,nonatomic)UITableView *MoreTableView;
@property(strong,nonatomic)NSArray *arrayTitle;
@property(strong,nonatomic)NSArray *arrayImage;
@end
#import "MoreViewController.h"
@interface MoreViewController ()
@property(strong,nonatomic)UILabel *lbl;
@end
@implementation MoreViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title=@"更多";
[self _loadData];
NSLog(@"%@",NSHomeDirectory());
}
-(void)_loadData
{
// 设置tableview的title和image
self.arrayTitle=@[@"清除缓存",@"给个评价",@"商务合作",@"检测行版本",@"欢迎页",@"关于"];
self.arrayImage=@[@"moreClear@2x",@"moreScore@2x",@"moreBusiness@2x",@"moreVersion@2x",@"moreWelcome@2x",@"moreAbout@2x"];
// 初始化UItableView
self.MoreTableView=[[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
// 设置UItableView的背景色
self.MoreTableView.backgroundColor=[UIColor blackColor];
// 指定代理
self.MoreTableView.delegate=self;
self.MoreTableView.dataSource=self;
// 分割线的样式
self.MoreTableView.separatorStyle=UITableViewCellSeparatorStyleSingleLine;
[self.view addSubview:self.MoreTableView];
// 指定唯一标识符
[self.MoreTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"MoreTableCell"];
self.lbl=[[UILabel alloc]init];
self.lbl.textColor=[UIColor whiteColor];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.arrayTitle.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MoreTableCell" forIndexPath:indexPath];
if (indexPath.row==0) {
self.lbl.frame= CGRectMake(200,20,200, cell.frame.size.height*0.5);
self.lbl.text=[NSString stringWithFormat:@"缓存为%.2fMB",[[SDImageCache sharedImageCache] checkTmpSize]];
[cell addSubview:self.lbl];
}
// 设置Cell的背景色
cell.backgroundColor=[UIColor blackColor];
// 设置title的文字颜色
cell.textLabel.textColor=[UI