IOS笔记

来源:互联网 发布:十大网络融资平台 编辑:程序博客网 时间:2024/06/05 07:47

fir.im     

测试分发网站

蒲公英



伯乐线    bole 在线      NShipster  

稀土掘金 

hadoop  云数据


​#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)  

​#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)  

​#define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)    

​#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)  

​#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)  

​#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))  

​#define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))    

​#define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)  

​#define IS_IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0)  

​#define IS_IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0)  

​#define IS_IPHONE_6P (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0) 


 AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];

    manager.responseSerializer = [AFHTTPResponseSerializer serializer];

    [manager GET:url parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {


    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {

        NSLog(@"%@",[[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]);

        

    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

        

    }];


http://seanooi.github.io/iOS-WebP/


[UIImage imageToWebP:[UIImage imageNamed:@"demo.jpg"] quality:quality alpha:alpha preset:WEBP_PRESET_DEFAULT completionBlock:^(NSData *result) {

  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);

  NSString *webPPath = [paths[0]stringByAppendingPathComponent:@"image.webp"];

  if (![result writeToFile:webPPathatomically:YES]) {

    NSLog(@"Failed to save file");

  }

} failureBlock:^(NSError *error) {

  NSLog(@"%@", error.localizedDescription);

}];


余洋  11:02:44

//读取缓存文件大小

+(float)fileSizeAtPath:(NSString *)path{

    NSFileManager *fileManager=[NSFileManager defaultManager];

    if([fileManager fileExistsAtPath:path]){

        long long size=[fileManager attributesOfItemAtPath:path error:nil].fileSize;

        return size/1024.0/1024.0;

    }

    return 0;

}


//清理缓存

+(void)clearCache:(NSString *)path{

    NSFileManager *fileManager=[NSFileManager defaultManager];

    if ([fileManager fileExistsAtPath:path]) {

        NSArray *childerFiles=[fileManager subpathsAtPath:path];

        for (NSString *fileName in childerFiles) {

            NSString *absolutePath=[path stringByAppendingPathComponent:fileName];

            [fileManager removeItemAtPath:absolutePath error:nil];

        }

    }

    [[SDImageCache sharedImageCache] cleanDisk];

}



葛超杰  20:07:15

-(void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation

{

   // NSLog(@"页面开始加载...");

    [MBProgressHUD showHUDAddedTo:self.view animated:YES];

    

    

}


-(void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error

{

   // NSLog(@"页面加载失败...");

}



-(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation

{

  //  NSLog(@"页面加载完成...");

    [MBProgressHUD hideAllHUDsForView:self.view animated:YES];

}


cell.accessoryType = UITableViewCellAccessoryNone;//cell没有任何的样式


cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;//cell的右边有一个小箭头,距离右边有十几像素;


cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;//cell右边有一个蓝色的圆形button;


cell.accessoryType = UITableViewCellAccessoryCheckmark;//cell右边的形状是对号;

简单的自适应label高度

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

    if (tableView != _tableView) {

        return 40;

    }

    return [selfheightForRow:_dataArray[indexPath.row][@"detail"]font:[UIFontboldSystemFontOfSize:20]labelSize:CGSizeMake(CGRectGetWidth(self.view.frame)-80,MAXFLOAT)];

}

- (CGFloat)heightForRow:(NSString *)aString font:(UIFont *)font labelSize:(CGSize)labelSize {

    CGSize size = [aStringsizeWithFont:font constrainedToSize:labelSizelineBreakMode:NSLineBreakByTruncatingTail];

    return size.height +10 + 20 + 20 +10;

}




0 0