标签:
1.定时器
[NSTimer sch
eduledTimerWithTimeInterval:多长时间变动一次 target:谁的计时器 selector:@selector(方法名) userInfo:定时器信息 repeats:是否重复]
如图,表示每1秒变动一次,给自己设定的计时器,调用下面的timerAc,描述为空,重复
2.通知
[[NSNotificationCenter defaultCenter]postNotificationName:@”通知名”object:通知设立者 userInfo:用户信息]
通知发布后,要有接收者,接受者接收通知后,做出相应的方法操作
接收通知,做出相应操作后要记得移除通知
主函数中
- (IBAction)notice:(id)sender {//在xib中拖出来的方法
UITabBarController *taabar = self.viewController.tabBarController;
//实现界面的跳转 要替跳转到的页面
[taabar setSelectedIndex:3];
//通知实现消息的交互
[[NSNotificationCenter defaultCenter] postNotificationName:@"enterNotice" object:nil];
//在与之对应的界面中接收通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(enterNotice:) name:@"enterNotice" object:nil];
//选择进入的界面中的哪一页
- (void)enterNotice:(NSNotification *)noti {
seg.seletedIndex = 1;
}
//实现界面的跳转 要替跳转到的页面
[self.viewController.tabBarController setSelectedIndex:1];
[[NSNotificationCenter defaultCenter] postNotificationName:@"enterTicket" object:nil userInfo:@{@"index":@"0"}];//userInfo:通知携带的内容详情@{key:index value:需要跳转的位置}
iOS中信息交互 通知方法传值
标签:
原文地址:http://www.cnblogs.com/liuxiaoping/p/5149634.html