清除缓冲

Posted 超神船长

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了清除缓冲相关的知识,希望对你有一定的参考价值。

1.包含

#import "SDImageCache.

2.当前大小

double size = [[SDImageCache sharedImageCache] getSize]/(1024 * 1024.0);

3,删除

- (NSString *)clearTmpPics
{
    [[SDImageCache sharedImageCache] clearDisk];
    [[SDImageCache sharedImageCache] clearMemory];//可有可无
    float tmpSize = [[SDImageCache sharedImageCache] getSize]/1024/1024;
    NSString *clearCacheName = tmpSize >= 1 ? [NSString stringWithFormat:@"%.1fMB",tmpSize] : [NSString stringWithFormat:@"%.0fKB",tmpSize * 1024];
    return clearCacheName;
}
clearCacheName = @“0KB”;

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (actionSheet.tag == 1)
    {  //清理缓存
        if (actionSheet.cancelButtonIndex != buttonIndex) {
            MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
            [self.navigationController.view addSubview:hud];
            hud.labelText = @"正在清除缓存....";
            __weak typeof (self)weakSelf = self;
            [hud showAnimated:YES whileExecutingBlock:^{
                // 模拟删除 要时间
                sleep(1.0);
            } completionBlock:^{
                [hud removeFromSuperview];
                NSString *clearCacheName =  [weakSelf clearTmpPics];
                [MBProgressHUD showSuccess:@"清理成功"];
                SliderModel *model = weakSelf.dataSource[1];
                model.content = clearCacheName;
                [weakSelf.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:1 inSection:0], nil]
                                          withRowAnimation:UITableViewRowAnimationNone];
            }];
            
        }
    }
}

 

 

以上是关于清除缓冲的主要内容,如果未能解决你的问题,请参考以下文章

如何从片段外部清除/重置地图?

如何在android中清除字节缓冲区

在 C# 中清除鼠标缓冲区

从缓冲区发送消息时,缓冲区会自动清除吗?

java缓冲字符字节输入输出流:java.io.BufferedReaderjava.io.BufferedWriterjava.io.BufferedInputStreamjava.io.(代码片段

[Go] 通过 17 个简短代码片段,切底弄懂 channel 基础