第19月第20天 UITableView:改变 TableHeaderView 的高度 获取目录大小

1.UITableView:改变 TableHeaderView 的高度

CGRect newFrame = headerView.frame;
newFrame.size.height = newFrame.size.height + webView.frame.size.height;
headerView.frame = newFrame;
[self.tableView setTableHeaderView:headerView];

http://www.cnblogs.com/ihojin/p/tableHeaderView-resizeheight.html

2.

static long long fileSizeAtPath(NSString *filePath) {
    struct stat st;
    
    //获取文件的一些信息,返回0的话代表执行成功
    if(lstat([filePath cStringUsingEncoding:NSUTF8StringEncoding], &st) == 0){
        
        //返回这个路径下文件的总大小
        return st.st_size;
    }
    return 0;
}


static long long folderSizeAtDirectory(NSString *folderPath) {
    NSFileManager* manager = [NSFileManager defaultManager];
    if (![manager fileExistsAtPath:folderPath]) {
        return 0;
    }
    NSEnumerator *childFilesEnumerator = [[manager subpathsAtPath:folderPath] objectEnumerator];
    NSString* fileName;
    long long folderSize = 0;
    while ((fileName = [childFilesEnumerator nextObject]) != nil) {
        NSString* fileAbsolutePath = [folderPath stringByAppendingPathComponent:fileName];
        folderSize += fileSizeAtPath(fileAbsolutePath);
    }
    return folderSize;
}

 https://github.com/HCat/trafficPolice

原文地址:https://www.cnblogs.com/javastart/p/8893311.html