|
|
@@ -24,6 +24,7 @@
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
|
|
|
+ [self registForNotification];
|
|
|
|
|
|
self.automaticallyAdjustsScrollViewInsets = NO;
|
|
|
// self.navigationItem.navi
|
|
|
@@ -35,10 +36,12 @@
|
|
|
backItem.title = @"Back";
|
|
|
self.navigationItem.backBarButtonItem = backItem;
|
|
|
|
|
|
+ AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
|
LoginViewController * loginVC = [ [UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginPanel"];
|
|
|
loginVC.loginSuccessful = ^(void)
|
|
|
{
|
|
|
+ appDelegate.isLogin = YES;
|
|
|
// 登陆成功后重新刷新tabbar
|
|
|
self.viewControllers = self.loginbar;
|
|
|
};
|
|
|
@@ -57,6 +60,7 @@
|
|
|
|
|
|
myVC.logoutSuccessful = ^(void)
|
|
|
{
|
|
|
+ appDelegate.isLogin = NO;
|
|
|
// 登陆成功后重新刷新tabbar
|
|
|
self.viewControllers = self.logoutbar;
|
|
|
};
|
|
|
@@ -93,4 +97,27 @@
|
|
|
}
|
|
|
*/
|
|
|
|
|
|
+- (void)dealloc {
|
|
|
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)registForNotification {
|
|
|
+
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:NotificationTypeLogout object:nil];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (void)handleNotification:(NSNotification *)notification {
|
|
|
+
|
|
|
+ AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
|
|
|
+ if ([notification.name isEqualToString:NotificationTypeLogout]) {
|
|
|
+
|
|
|
+ [appDelegate Logout];
|
|
|
+ [(LoginViewController *)self.logoutbar.firstObject clear];
|
|
|
+ self.viewControllers = self.logoutbar;
|
|
|
+ self.selectedIndex = 0;
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
@end
|