2017年3月22日

IOS 单例模式

摘要: 单例模式: 1.永远只分配一块内存来创建对象 2.提供一个类方法, 返回内部唯一的一个对象(一个实例) 3.最好保证init方法也只初始化一次 单例模式 :定义一份变量(整个程序运行过程中, 只有1份) //static id _instance; ARC 与非ARC 控制内存内存 // ## : 阅读全文

posted @ 2017-03-22 22:01 守望星空 阅读(126) 评论(0) 推荐(0)

IOS 线程的总结(及cell的图片下载)

摘要: 零、线程的注意点(掌握) 1.不要同时开太多的线程(1~3条线程即可,不要超过5条)2.线程概念1> 主线程 : UI线程,显示、刷新UI界面,处理UI控件的事件2> 子线程 : 后台线程,异步线程3.不要把耗时的操作放在主线程,要放在子线程中执行 一、NSThread(掌握) 1.创建和启动线程的 阅读全文

posted @ 2017-03-22 21:43 守望星空 阅读(230) 评论(0) 推荐(0)

IOS GCD03-其他用法

摘要: #define global_queue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) #define main_queue dispatch_get_main_queue() #import "HMViewController.h" @interface HMViewController () @property... 阅读全文

posted @ 2017-03-22 21:30 守望星空 阅读(172) 评论(0) 推荐(0)

IOS GCD (事例下载图片)

摘要: @interface HMViewController () @property (weak, nonatomic) IBOutlet UIImageView *imageView; @end @implementation HMViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any add... 阅读全文

posted @ 2017-03-22 21:25 守望星空 阅读(130) 评论(0) 推荐(0)

IOS GCD(线程的 串行、并发 基本使用)

摘要: 任务和队列 队列的类型 容易混淆的术语 全局并发队列的优先级 各种队列的执行效果 注意使用sync函数往当前串行队列中添加任务,会卡住当前的串行队列 线程间通信示例 单例模式 阅读全文

posted @ 2017-03-22 21:22 守望星空 阅读(262) 评论(0) 推荐(0)

IOS NSThread 线程间通信

摘要: @interface HMViewController () @property (weak, nonatomic) IBOutlet UIImageView *imageView; @end @implementation HMViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any add... 阅读全文

posted @ 2017-03-22 21:10 守望星空 阅读(116) 评论(0) 推荐(0)

IOS NSThread(线程同步)

摘要: @interface HMViewController () /** 剩余票数 */ @property (nonatomic, assign) int leftTicketsCount; @property (nonatomic, strong) NSThread *thread0; @property (nonatomic, strong) NSThread *thread1; @pro... 阅读全文

posted @ 2017-03-22 21:05 守望星空 阅读(175) 评论(0) 推荐(0)

IOS 多线程-NSThread 和线程状态

摘要: 线程的状态 阅读全文

posted @ 2017-03-22 20:32 守望星空 阅读(138) 评论(0) 推荐(0)

IOS 多线程-pthread

摘要: #import @interface HMViewController () - (IBAction)btnClick; @end @implementation HMViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading t... 阅读全文

posted @ 2017-03-22 20:31 守望星空 阅读(103) 评论(0) 推荐(0)

IOS 多线程

摘要: 多线程的原理 ● 多线程的原理 ● 同一时间,CPU只能处理1条线程,只有1条线程在工作(执行) ● 多线程并发(同时)执行,其实是CPU快速地在多条线程之间调度(切换) ● 如果CPU调度线程的时间足够快,就造成了多线程并发执行的假象 ● 思考:如果线程非常非常多,会发生什么情况? • CPU会在 阅读全文

posted @ 2017-03-22 19:53 守望星空 阅读(97) 评论(0) 推荐(0)

IOS 线程描述

摘要: ●什么是线程 ● 1个进程要想执行任务,必须得有线程(每1个进程至少要有1条线程) ● 线程是进程的基本执行单元,一个进程(程序)的所有任务都在线程中执行 ● 比如使用酷狗播放音乐、使用迅雷下载电影,都需要在线程中执行 线程的串行 ● 1个线程中任务的执行是串行的 ● 如果要在1个线程中执行多个任务 阅读全文

posted @ 2017-03-22 17:55 守望星空 阅读(106) 评论(0) 推荐(0)

IOS 进程描述

摘要: ● 什么是进程 ● 进程是指在系统中正在运行的一个应用程序 ● 每个进程之间是独立的,每个进程均运行在其专用且受保护的内存空间内 ● 通过“活动监视器”可以查看Mac系统中所开启的进程 ● 什么是进程 ● 进程是指在系统中正在运行的一个应用程序 ● 每个进程之间是独立的,每个进程均运行在其专用且受保 阅读全文

posted @ 2017-03-22 15:00 守望星空 阅读(142) 评论(0) 推荐(0)

IOS 强指针(strong)和弱指针(weak)

摘要: // strong 强指针 // weak 弱指针 // ARC, 只要对象没有强指针就会自动释放 // OC中默认都是强指针 阅读全文

posted @ 2017-03-22 14:58 守望星空 阅读(297) 评论(0) 推荐(0)

IOS autosizing(设置控件的固定位置大小)

摘要: - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. /* UIViewAutoresizingNone = 0, 什么都没有设置 UIV... 阅读全文

posted @ 2017-03-22 14:51 守望星空 阅读(194) 评论(0) 推荐(0)

IOS UIActivityIndicatorView动画

摘要: ● 是一个旋转进度轮,可以用来告知用户有一个操作正在进行中,一般 用initWithActivityIndicatorStyle初始化 ● 方法解析: ● - (void)startAnimating; 开始动画 ● - (void)stopAnimating; 停止动画 ● - (BOOL)isA 阅读全文

posted @ 2017-03-22 14:23 守望星空 阅读(302) 评论(0) 推荐(0)

IOS UIImageView的帧动画

摘要: ● UIImageView可以让一系列的图片在特定的时间内按顺序显示 ● 相关属性解析: ● animationImages:要显示的图片(一个装着UIImage的NSArray) ● animationDuration:完整地显示一次animationImages中的所有图 片所需的时间 ● an 阅读全文

posted @ 2017-03-22 14:17 守望星空 阅读(946) 评论(0) 推荐(0)

IOS Block动画

摘要: ● + (void)transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options comp 阅读全文

posted @ 2017-03-22 14:15 守望星空 阅读(154) 评论(0) 推荐(0)

IOS UIView动画(封装动画)

摘要: ● UIKit直接将动画集成到UIView类中,当内部的一些属性发生改变时,UIView 将为这些改变提供动画支持 ● 执行动画所需要的工作由UIView类自动完成,但仍要在希望执行动画时通知视 图,为此需要将改变属性的代码放在[UIView beginAnimations:nil context: 阅读全文

posted @ 2017-03-22 14:13 守望星空 阅读(194) 评论(0) 推荐(0)

IOS 核心动画(Core Animation)

摘要: Core Animation,中文翻译为核心动画,它是一组非常强大的动画处理API,使用它 能做出非常炫丽的动画效果,而且往往是事半功倍。也就是说,使用少量的代码就 可以实现非常强大的功能。 Core Animation可以用在Mac OS X和iOS平台。 Core Animation的动画执行过 阅读全文

posted @ 2017-03-22 13:59 守望星空 阅读(315) 评论(0) 推荐(0)

IOS 隐式动画(非Root Layer)

摘要: ● 每一个UIView内部都默认关联着一个CALayer,我们可用称这个Layer为Root Layer(根 层) ● 所有的非Root Layer,也就是手动创建的CALayer对象,都存在着隐式动画 ● 什么是隐式动画? ➢ 当对非Root Layer的部分属性进行修改时,默认会自动产生一些动画 阅读全文

posted @ 2017-03-22 13:25 守望星空 阅读(235) 评论(0) 推荐(0)

IOS 自定义Layer(图层)

摘要: 方式2: NJLayer.h / .m @implementation NJLayer // 重写该方法, 在该方法中给layer上绘制图形 // 注意CALayer中的drawInContext方法, 不会自动调用 // 只能自己通过setNeedDisplay方法调用 - (void)drawI 阅读全文

posted @ 2017-03-22 13:14 守望星空 阅读(225) 评论(0) 推荐(0)

IOS CALayer基本使用 (图层)

摘要: ● 其实UIView之所以能显示在屏幕上,完全是因为它内部的一个图层(CALayer) ● 在创建UIView对象时,UIView内部会自动创建一个图层(即CALayer对象),通过UIView 的layer属性可以访问这个层 @property(nonatomic,readonly,retain) 阅读全文

posted @ 2017-03-22 13:11 守望星空 阅读(279) 评论(0) 推荐(0)

IOS 拖拽事件(手势识别)

摘要: @interface NJViewController () @property (weak, nonatomic) IBOutlet UIView *customView; @end @implementation NJViewController - (void)viewDidLoad { [super viewDidLoad]; UIPanGestureRecog... 阅读全文

posted @ 2017-03-22 12:56 守望星空 阅读(270) 评论(0) 推荐(0)

IOS 旋转+缩放(手势识别)

摘要: @interface NJViewController () @property (weak, nonatomic) IBOutlet UIImageView *iconView; @end @implementation NJViewController - (void)viewDidLoad { [super viewDidLoad]; [self pic... 阅读全文

posted @ 2017-03-22 12:52 守望星空 阅读(226) 评论(0) 推荐(0)

IOS 长按+轻扫(手势识别)

摘要: @interface NJViewController () @property (weak, nonatomic) IBOutlet UIView *customView; @end @implementation NJViewController - (void)viewDidLoad { [super viewDidLoad]; // 向上 UI... 阅读全文

posted @ 2017-03-22 12:44 守望星空 阅读(664) 评论(0) 推荐(0)

IOS 绘制画画板(封装上下文)

摘要: 封装上下文 UIImage (CaptureView).h / .m @interface UIImage (CaptureView) + (UIImage *)captureImageWithView:(UIView *)view; @end #import "UIImage+captureVie 阅读全文

posted @ 2017-03-22 11:13 守望星空 阅读(167) 评论(0) 推荐(0)

IOS 截屏(保存到相册中)

摘要: @interface NJViewController () /** * 点击截屏按钮 */ - (IBAction)captureView:(UIButton *)sender; /** * 白色view */ @property (weak, nonatomic) IBOutlet UIView *customView; @end @implementation NJ... 阅读全文

posted @ 2017-03-22 11:05 守望星空 阅读(263) 评论(0) 推荐(0)

IOS 九宫图解锁(封装)

摘要: NJLockView.h /.m @class NJLockView; @protocol NJLockViewDelegate <NSObject> - (void)lockViewDidClick:(NJLockView *)lockView andPwd:(NSString *)pwd; @e 阅读全文

posted @ 2017-03-22 10:52 守望星空 阅读(194) 评论(0) 推荐(0)

IOS 响应者链条 and UIGestureRecognizer 手势识别器)

摘要: 一次完整的触摸事件的传递响应的过程 UIAppliction --> UIWiondw -->递归找到最适合处理事件的控件 控件调用touches方法-->判断是否实现touches方法-->没有实现默认会将事件传递给上一个响应者-->找到上一个响应者 1.响应者链条: 由很多响应者链接在一起组合起 阅读全文

posted @ 2017-03-22 10:35 守望星空 阅读(275) 评论(0) 推荐(0)

IOS view拖拽(触摸事件)

摘要: • iOS中的事件可以分为3大类型 触摸事件 加速计事件 远程控制事件 响应者对象 • 在iOS中不是任何对象都能处理事件,只有继承了UIResponder的对象才能接收并处理事 件。我们称之为“响应者对象” • UIApplication、UIViewController、UIView都继承自UI 阅读全文

posted @ 2017-03-22 10:09 守望星空 阅读(2259) 评论(0) 推荐(0)

IOS 绘制条纹背景

摘要: @interface NJViewController () @property (weak, nonatomic) IBOutlet UITextView *contentView; - (IBAction)preBtnClick:(id)sender; - (IBAction)nextBtnClick:(id)sender; @property (nonatomic, assign) ... 阅读全文

posted @ 2017-03-22 09:39 守望星空 阅读(311) 评论(0) 推荐(0)

导航