关于NSNotificationCenter,跟我前面那篇文章是一样的,一直想使用这个,基于种种原因,一直没去涉及,最近因为新浪微博的登录,so,用到了,就简单记录一下吧。
第一步:简单的写个方法
1 2 3 4 5 6 7 8 9 10 11 12 13
| - (void)addObservers { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange:) name:@"UIDeviceOrientationDidChangeNotification" object:nil]; }
- (void)removeObservers{ [[NSNotificationCenter defaultCenter] removeObserver:self name:@"UIDeviceOrientationDidChangeNotification" object:nil]; }
|
是这样的,添加一个通知,然后去调用方法
这个方法是做什么的呢
1 2 3 4
| - (void)deviceOrientationDidChange:(id)object { }
|
你想做什么都可以,因为只是一个例子,你可以抽象的超长发挥的。我没用上,知道这么用就好了先。