sinaBlog中小知识总结

1、上拉刷新的时候记得移除老的数据(同样应用于其他地方)

        if (vc.currentPage == 1)

        {

            //上拉加载 记得移除新的

            [vc.totalArr removeAllObjects];

        }

2、currentPage 设定初始值 否则第一次上拉的话会重新加载一次

3、tableView的返回高度的方法先加载 cell后加载 因而要向获得高度只能用类调方法 不能用对象

4、算时间差的方法

double timeCha = [nowDate timeIntervalSinceDate:date];

5、字符串换行

CGFloat height = [[str objectForKey:@"text"] boundingRectWithSize:CGSizeMake(304, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20]} context:nil].size.height;

6、image转data

NSData *data = UIImagePNGRepresentation(_imgView.image);

7、url转image

UIImage *image  = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",[str objectForKey:@"original_pic"]]]]];

 

 

 

 

 

原文地址:https://www.cnblogs.com/dlwj/p/4893832.html