- 博客(23)
- 收藏
- 关注
原创 利用AFnetworking
AFHTTPSessionManager *manager=[[AFHTTPSessionManager alloc]init]; //拼接参数 NSMutableDictionary *parameters=[NSMutableDictionary dictionary]; parameters[@"a"]=@"list";
2017-03-14 21:50:38
312
原创 UICollectionView如何创建
在tableView中创建CollectionView不需要管她的宽度。 //设置collectionView布局 UICollectionViewLayout *layout=[[UICollectionViewLayout alloc]init]; //创建collectionView UICollectionView
2017-03-14 20:54:54
356
原创 scrollView的一些功能
//取消滚动条 scrollView.showsVerticalScrollIndicator=NO; scrollView.showsHorizontalScrollIndicator=NO; //可以翻页 scrollView.pagingEnabled=YES;
2017-03-11 00:02:13
291
原创 iOS中发送HTTP请求的方案
1.苹果原生(自带) NSURLConnection:用法简单,最古老最经典最直接的一种方案 NSURLSession:功能比NSURLConnection更加强大,苹果目前比较推荐只用这种技术 CFNetwork:NSURL的底层。纯c语言 第三方框架 AFNetworking: MKNetworkKit NSURLConnection的使用步骤 1.创建
2017-03-08 15:06:46
342
原创 tableView 分割线宽度没占据整个屏幕的宽度
解决办法 self.tableView.separatorInset=UIEdgeInsetsZero; 把内边距设为0;
2017-03-07 15:28:38
304
原创 将正方形图片转成圆形图片
//从xib加载就会调用 调用一次 - (void)awakeFromNib { [super awakeFromNib]; // Initialization code _itemView.layer.cornerRadius=30; _itemView.layer.masksToBounds=YES; 第二种方
2017-03-07 15:09:08
3604
原创 JSON解析代码
方法1是JSON转OC对象 方法2是OC对象转JSON 以下是示例代码 #import "ViewController.h" @interface ViewController () @end @implementation ViewController -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
2017-02-26 14:43:01
379
原创 利用NSConnection发送POST请求
跟GET请求旅游不同,以下是示例代码 #import "ViewController.h" @interface ViewController () @end @implementation ViewController -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self asyncPos
2017-02-25 18:03:55
325
原创 NNSURLConnection 发送GET请求
1.苹果原生(自带) NSURLConnection:用法简单,最古老最经典最直接的一种方案 NSURLSession:功能比NSURLConnection更加强大,苹果目前比较推荐只用这种技术 CFNetwork:NSURL的底层。纯c语言 第三方框架 AFNetworking: MKNetworkKit NSURLConnection的使用步骤 1.创建
2017-02-25 16:24:24
231
原创 网络基本概念
Get请求: 在请求URL后面以?的形式加上给服务器的参数,多个参数之间用&隔开 由于浏览器和服务器对URL长度有限制,因此在URL后面附带的参数是有限制的,通常不能超过1kb POST请求: 发给服务器的参数全部放在请求体中 理论上,post传递的数据量没有限制(具体还得看服务器的处理能) GET和POST的选择 如果要传递大量数据,比如文件上传 ,只能用POST请
2017-02-24 18:29:41
305
原创 利用runloop开启常驻线程
Runloop中自动释放池的创建和释放 第一次创建:启动runloop 最后一次销毁:runloop退出的时候 其他时候的创建和销毁:当runloop即将睡眠的时候销毁之前的释放池,重新创建一个新的 runloop在开发中的应用场景: 最长使用的就是开一个常驻线程 (让一个子线程不进入消亡状态,等待其他线程发来详细,处理其他时间) 在子线程中开启一个定时器 在子线程中
2017-02-24 15:20:11
1650
原创 GCD定时器示例代码
#import "ViewController.h" @interface ViewController () @property (nonatomic,strong)dispatch_source_t timer; @end @implementation ViewController -(void)touchesBegan:(NSSet *)touches withEvent:(UIE
2017-02-24 13:09:04
245
原创 runLoop运行模式示例代码
runLoop运行模式示例代码 #import "ViewController.h" @interface ViewController () @end @implementation ViewController -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { // [self timer2];
2017-02-24 01:14:48
356
原创 NSCache
NSCache 示例代码如下 #import "ViewController.h" @interface ViewController () @property (nonatomic, strong)NSCache* cache; @end @implementation ViewController -(NSCache *)cache { if (_cache==nil
2017-02-23 23:16:37
253
原创 SDWebImage的一些细节
//清空缓存 //cleanDisk:清除过期缓存,计算当前缓存的大小,和设置的最大缓存数量比较,如果超出那么会继续删除(按照文件穿件的先后顺序) //clearDisk:直接删除重新创建 //过期时间:7天 [[SDWebImageManager sharedManager].imageCache cleanDisk];
2017-02-23 16:47:17
295
原创 NSOperation实现线程之间通信
方法一为下载一张图片 方法二为 下载两张图片拼接成一张 #import "ViewController.h" @interface ViewController () @property (weak, nonatomic) IBOutlet UIImageView *imageView; @end @implementation ViewController -(voi
2017-02-22 03:46:55
340
原创 NSOperation的监听和依赖
示例代码 #import "ViewController.h" @interface ViewController () @end @implementation ViewController -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSOperationQueue *qu
2017-02-22 02:58:29
285
原创 NSOperation如何开线程
创建队列 GCD: 串行:create/主队列 并发:create/全局并发队列 NSOperation: 主队列:[NSOperationQueue mainQueue] 和GCD中的主队列一样,串行队列 非主队列 [[NSOperationQueue alloc]init] 非常特殊(同时具备了并发和串行的功能) 默认情况下非主队列是并发队列 #import "ViewCont
2017-02-21 21:21:50
263
原创 NSOperation
#import "ViewController.h" @interface ViewController () @end @implementation ViewController -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self blockOperation]; } -(
2017-02-21 21:18:51
216
原创 单例模式
1。 arc环境下: 提供全局变量 static Tool *instance +(instance)allocWithZone:(struct _NSZone *)zone { if(instance==nil){ instance=[super allocWithZone:zone]; } return instance; } 加互斥锁的方法
2017-02-21 15:38:43
217
原创 GCD常用函数
1. ios延迟执行的几种方法 [selfperformSelector:@selector(方法)withObject:nilafterDelay:2.0]; [NSTimerscheduledTimerWithTimeInterval:2.0target:selfselector:@selector(方法)userInfo:nilrepeats:NO
2017-02-21 01:07:46
1192
原创 GCD线程之间通信
因为在开发过程中所有的耗时操作必须在主线程中执行,所以线程之间的通信很重要,以下是示例代码 #import "ViewController.h" @interface ViewController () @property (strong, nonatomic) IBOutlet UIImageView *imageView; @end @implementation ViewContro
2017-02-21 00:32:24
431
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅