网络监听用到的类为Reachability.h,这个Xcode项目里面是不自带的,需要从github上面下载,在使用的时候记着导入SystemConfiguration.framework。 首先是在AppDelegate.m中设置网络监听 [[NSNotificationCenter d...
分类:
移动开发 时间:
2015-03-28 21:56:43
阅读次数:
151
NSNotificationCenter通知中心提供了一种在程序内广播信息的途径,一个NSNotificationCenter对象本质上是一个通知分发表(notification dispatch table)。每一个运行中的Cocoa程序有一个默认的通知中心,一般不用自己创建。一个NSNotifi...
分类:
其他好文 时间:
2015-03-20 18:10:27
阅读次数:
124
1.通知中心(NSNotificationCenter)1.1.每一个应用程序都有一个通知中心(NSNotificationCenter*)实例,专门负责协助不同对象之间的消息通信1.2.这就是观察者模式(Observer),任何一个对象都可以向通知中心发布通知(NSNotification*),描...
分类:
其他好文 时间:
2015-03-18 23:09:07
阅读次数:
216
先在消息中心注册通知
[[NSNotificationCenter defaultCenter] addObserver:observer selector:@selector(”要执行的函数“)
name:@"NAME"(需要观察的对象) object:nil];
然后发送通知
[[NSNotificationCenter
defaultCenter] postNotifica...
分类:
移动开发 时间:
2015-03-18 17:59:46
阅读次数:
132
首先上代码:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIButton *button = [UIButton buttonWithType:UIButtonTyp...
分类:
其他好文 时间:
2015-03-17 20:16:32
阅读次数:
156
NSNotificationCenter消息通信机制介绍(KVO)
作用:NSNotificationCenter是专门供程序中不同类间的消息通信而设置的.
注册通知:即要在什么地方接受消息
???????????????[[NSNotificationCenter?d...
分类:
其他好文 时间:
2015-03-11 23:35:09
阅读次数:
305
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(KeyBoardWillChange:) name:UIKeyboardWillChangeFrameNotification object:nil];/...
分类:
其他好文 时间:
2015-03-11 22:55:33
阅读次数:
135
NSNotificationCenter是专门供程序中不同类间的消息通信而设置的.注册通知:[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mytest:) name:@"mytest" objec....
分类:
移动开发 时间:
2015-03-06 18:52:22
阅读次数:
154
1.监听UITextField输入- (void)viewDidLoad{ [super viewDidLoad]; //监听文本输入框的改变 //1.拿到通知中心 NSNotificationCenter *center = [NSNotificationC...
分类:
其他好文 时间:
2015-03-05 10:32:12
阅读次数:
122
弹出键盘操作
//1.定制通知
//在初始化时定制通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(KeyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
//2.对应的方...
分类:
其他好文 时间:
2015-02-13 18:41:06
阅读次数:
135