iOS中设置清除缓存功能的实现方法

2020-01-21 00:05:34于海丽


#import "GYLSettingViewController.h"
#import "GYLClearCacheCell.h"
@implementation GYLSettingViewController
static NSString * const GYLClearCacheCellID = @"ClearCache";
static NSString * const GYLSettingCellID = @"Setting";
- (instancetype)init
{
  return [self initWithStyle:UITableViewStyleGrouped];
}
- (void)viewDidLoad
{
  [super viewDidLoad];
  self.view.backgroundColor = GYLBGColor;
  self.navigationItem.title = @"设置";
  [self.tableView registerClass:[GYLClearCacheCell class] forCellReuseIdentifier:GYLClearCacheCellID];
  [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:GYLSettingCellID];  
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
  return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
  return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{ 
  if (indexPath.section == 0 && indexPath.row == 0) {
    return [[GYLClearCacheCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:GYLClearCacheCellID];   
  }
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:GYLSettingCellID];
  cell.textLabel.text = [NSString stringWithFormat:@"section-%zd,row--%zd",indexPath.section,indexPath.row];
  return cell;
}
@end

7. 效果

ios,清除缓存功能

计算文件大小

ios,清除缓存功能

正在清除缓存

ios,清除缓存功能

清除完毕

总结

以上所述是小编给大家介绍的iOS中设置清除缓存功能的实现方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对ASPKU网站的支持!