从A——>B
在B界面点击事件中执行,返回A
[self dismissViewControllerAnimated:YES completion:^{
[[NSNotificationCenter defaultCenter] postNotificationName:@"loginsuccess" object:self];
}];
在A界面注册广播在ViewWillAppear中执行NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self
selector:@selector(handleColorChange:)
name:@"loginsuccess"
object:nil];
并且在A界面中添加接受广播后执行方法-(void)handleColorChange:(NSNotification*)sender{
NSLog(@"%@",sender);
}
iOS登录成功通知传递
本文介绍了一种在iOS应用中实现登录成功后通过通知中心发送通知,并在另一个界面接收此通知的方法。具体步骤包括:从界面A跳转到界面B进行登录操作;登录成功后在界面B发布'loginsuccess'通知;界面A通过NSNotificationCenter监听该通知并在收到后执行特定操作。
2139

被折叠的 条评论
为什么被折叠?



